pcf.particle.aws.lambda_function package¶
Submodules¶
pcf.particle.aws.lambda_function.lambda_function module¶
-
class
pcf.particle.aws.lambda_function.lambda_function.
LambdaFunction
(particle_definition)¶ Bases:
pcf.core.aws_resource.AWSResource
This is the implementation of Amazon’s lambda service. This particle works with function code in a zipfile located locally and in s3. Note that having a zipfile locally versus s3 has a slightly different configuration format.
-
RETURN_PARAM_FILTER
= {'CodeSha256', 'DeadLetterConfig', 'Description', 'Environment', 'FunctionName', 'Handler', 'KMSKeyArn', 'MemorySize', 'Role', 'Runtime', 'Timeout', 'TracingConfig', 'VpcConfig'}¶
-
S3_PARAM_CONVERSIONS
= {'S3Bucket': 'Bucket', 'S3Key': 'Key', 's3ObjectVersion': 'VersionId'}¶
-
START_PARAM_FILTER
= {'Code', 'DeadLetterConfig', 'Description', 'Environment', 'FunctionName', 'Handler', 'KMSKeyArn', 'MemorySize', 'Publish', 'Role', 'Runtime', 'Tags', 'Timeout', 'TracingConfig', 'VpcConfig'}¶
-
UNIQUE_KEYS
= ['aws_resource.FunctionName']¶
-
UPDATE_PARAM_FILTER
= {'DeadLetterConfig', 'Description', 'Environment', 'FunctionName', 'Handler', 'KMSKeyArn', 'MemorySize', 'Role', 'Runtime', 'Timeout', 'TracingConfig', 'VpcConfig'}¶
-
_LambdaFunction__s3_to_sha256
()¶ Looks to see if the zipfile located in s3 has a tag with the latest sha256. If there is no tag it calculates the hash and adds the tag.
Returns: base 64 hash
-
_LambdaFunction__zip_local_to_sha256
()¶ Hashes the contents of a local zipfile using sha256
Returns: base 64 hash
-
_LambdaFunction__zipfile_to_sha256
()¶ returns the contents of the lambda code as a sha256 hash. There is a separate process for the code stored locally or in s3
Returns: hash
-
_set_unique_keys
()¶ Logic that sets keys from state definition that are used to uniquely identify the Lambda Function
-
_start
()¶ Starts the lambda particle that matches desired state definition
Returns: response of boto3 create_function
-
_stop
()¶ Lambda function does not have a stopped state so calls terminate.
-
_terminate
()¶ Starts the lambda particle that matches the function_name
Returns: response of boto3 delete_function
-
_update
()¶ Updates the lambda function particle to match current state definition. There is a different function call if the update is the function code in the zipfile or a configuration variable.
-
file_get_contents
()¶ Function gets and reads contents of local zipfile
Returns: file contents
-
flavor
= 'lambda_function'¶
-
get_status
()¶ Calls the get function configuration boto call and returns status missing if the function does not exist. Otherwise will return the current definition.
Returns: current definition
-
is_state_definition_equivalent
()¶ Compares the desired state and current state definitions.
Returns: bool
-
s3client
¶ Create a s3 client if the zipfile is located in s3.
Returns: s3 client
-
sync_state
()¶ Lambda function implementation of sync state. Calls get status and sets the current state.
-