chili-pepper
chili-pepper

chili_pepper package

Submodules

chili_pepper.app module

class chili_pepper.app.App(app_name, config=None)[source]

Bases: object

Cloud-agnostic App class

App is the main class for applications that use Chili-Pepper.

property app_name

The application name.

task(environment_variables=None)[source]

The decorator to denote tasks. It must be implemented by cloud-specific App child classes.

Parameters

environment_variables – Environment variables to apply to the task

property task_functions

The task functions identified with the @app.task decorator

class chili_pepper.app.AppProvider[source]

Bases: enum.Enum

Enum to identify the serverless provider.

Currently unused.

AWS = 1
class chili_pepper.app.AwsAllowPermission(allow_actions, allow_resources, sid=None)[source]

Bases: object

Simple wrapper around an AWS IAM rule allowing permission(s) to resource(s)

property allow_actions
Returns

Actions to grant permissions

Return type

List[str]

property allow_resources
Returns

The resources that should be granted permissions

Return type

List[str]

property sid
Returns

The sid of this policy statement

Return type

Optional[str]

statement()[source]

Generate the statement object for these permissions

Returns

The statement object granting permissions

Return type

awsacs.aws.Statement

class chili_pepper.app.AwsApp(app_name, config=None)[source]

Bases: chili_pepper.app.App

property allow_policy_permissions

Extra permissions to allow functions in this app

Returns

The extra permissions that should be granted

Return type

List[AwsAllowPermission]

property bucket_name

The AWS S3 bucket name that holds the lambda deployment packages

Returns

The bucket name

Return type

str

property default_tags
Returns

The default tags to assign to all resources created when deploying this App

Return type

Dict

property kms_key_arn

The KMS key arn to use, or None to use the default AWS key

Returns

The KMS key arn, or None to use the default key

Return type

Optional[str]

property runtime

The AWS lambda runtime identifier.

Returns

The runtime identifier

Return type

str

property security_group_ids

Security Group IDs for the lambda function

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-vpcconfig.html

Returns

The security group IDs for the lambda function

Return type

List[str]

property subnet_ids

Subnet IDs for the lambda function

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-vpcconfig.html

Returns

The subnet IDs for the lambda function

Return type

List[str]

task(environment_variables=None, memory=None, timeout=None, tags=None, activate_tracing=False)[source]

The decorator to denote tasks. It must be implemented by cloud-specific App child classes.

Parameters

environment_variables – Environment variables to apply to the task

class chili_pepper.app.ChiliPepper[source]

Bases: object

create_app(app_name, app_provider=<AppProvider.AWS: 1>, config=None)[source]

[summary]

Parameters
  • app_name ([type]) – [description]

  • app_provider ([type], optional) – [description]. Defaults to AppProvider.AWS.

  • config ([type], optional) – [description]. Defaults to None.

Raises

ChiliPepperException – [description]

Returns

[description]

Return type

[type]

exception chili_pepper.app.InvalidFunctionSignature[source]

Bases: chili_pepper.exception.ChiliPepperException

Function Signature does not match required specifications

Cloud providers require that functions have a specific signature. This exception is raised when a task does not match the required signature.

exception chili_pepper.app.InvocationError[source]

Bases: chili_pepper.exception.ChiliPepperException

Raised when there was a problem invoking the serverless function

exception chili_pepper.app.MissingArgumentError[source]

Bases: chili_pepper.exception.ChiliPepperException

Raised when there is a missing or incorrect argument in a method

class chili_pepper.app.Result(lambda_function_name, event)[source]

Bases: object

Task result object

Result wraps the information returned when the serverless function is invoked.

get()[source]

Get the response from the serverless execution.

This is a potentially blocking call.

It will retrieve the return payload from the serverless function. If it is called before the serverless function has finished, get will block until the serverless function returns.

Raises

InvocationError – Raises if something goes retrieving the return payload of the serverless function.

Returns

The return payload of the serverless function

Return type

dict

get_log_result()[source]

Get the log result from the serverless invocation.

This is potentially a blocking call.

Returns

The last 4 KB of the execution log

Return type

str

start()[source]

Start executing the serverless function

Invokes the serverless function.

For AWS, this invokes the Lambda in a thread, since the only way to get results is to call synchronously. By putting the invoke call in a therad, it will not block the main application thread.

Returns

The thread running the lambda

Return type

Thread

class chili_pepper.app.TaskFunction(func, environment_variables=None, memory=None, timeout=None, tags=None, activate_tracing=False)[source]

Bases: object

A wrapper around python functions that can be serverlessly deployed and executed by chili-pepper

property activate_tracing

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-tracingconfig

This will return True if and only if True was passed to the constructor - any other value, even if it is Truthy, will not activate tracing

Returns

True if tracing should be activate, False otherwise

Return type

bool

property environment_variables
Returns

The environment variable overrides for this function

Return type

dict

property func
Returns

The python function

Return type

builtins.function

property memory

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-memorysize

Returns

The memory allocation to grant to this serverless function

Return type

Optional[int]

property tags

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-tags

Returns

Tags for the serverless function

Return type

Dict

property timeout

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-timeout

Returns

Timeout value for the serverless function

Return type

Optional[int]

chili_pepper.config module

class chili_pepper.config.Config[source]

Bases: collections.abc.MutableMapping

Chili-Pepper specific configuration

chili_pepper.deployer module

class chili_pepper.deployer.Deployer(app)[source]

Bases: object

deploy(dest, app_dir)[source]

Deploys the chili-pepper app

Parameters
  • dest (Path) – The destination for the deployment package.

  • app_dir (Path) – The location of the application source code.

Returns

The cloudformation template that was deployed to AWS.

Return type

str

get_function_id(python_function)[source]

Get a unique identifier for the serverless function

Parameters

python_function (builtins.function) – The python function. Must have been included in the Chili-Pepper app.

Returns

The unique serverless function identification string

Return type

str

chili_pepper.deployer.TITLE_SPLIT_REGEX_HACK = re.compile('[^a-zA-Z0-9]')

chili_pepper.exception module

exception chili_pepper.exception.ChiliPepperException[source]

Bases: Exception

Chili Pepper Exceptions

chili_pepper.main module

class chili_pepper.main.CLI[source]

Bases: object

Implements the chili command line interface

deploy(args)[source]

Deploys a Chili-Pepper app

Parameters

args (argparse.Namespace) – Arguments passed to the command line.

chili_pepper.main.main()[source]

Main Chili-Pepper command line interface handler

Module contents