salt.modules.boto_lambda module

Connection module for Amazon Lambda

New in version 2016.3.0.

depends

  • boto

  • boto3

The dependencies listed above can be installed via package or pip.

configuration

This module accepts explicit Lambda credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no further configuration is necessary. More Information available here.

If IAM roles are not used you need to specify them either in a pillar or in the minion's config file:

lambda.keyid: GKTADJGHEIQSXMKKRBJ08H
lambda.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

A region may also be specified in the configuration:

lambda.region: us-east-1

If a region is not specified, the default is us-east-1.

It's also possible to specify key, keyid and region via a profile, either as a passed in dict, or as a string to pull from pillars or minion config:

myprofile:
    keyid: GKTADJGHEIQSXMKKRBJ08H
    key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
    region: us-east-1

Changed in version 2015.8.0: All methods now return a dictionary. Create and delete methods return:

created: true

or

created: false
error:
  message: error message

Request methods (e.g., describe_function) return:

function:
  - {...}
  - {...}

or

error:
  message: error message
salt.modules.boto_lambda.add_permission(FunctionName, StatementId, Action, Principal, SourceArn=None, SourceAccount=None, Qualifier=None, region=None, key=None, keyid=None, profile=None)

Add a permission to a lambda function.

Returns {added: true} if the permission was added and returns {added: False} if the permission was not added.

CLI Example:

salt myminion boto_lamba.add_permission my_function my_id "lambda:*" \
                   s3.amazonaws.com aws:arn::::bucket-name \
                   aws-account-id
salt.modules.boto_lambda.alias_exists(FunctionName, Name, region=None, key=None, keyid=None, profile=None)

Given a function name and alias name, check to see if the given alias exists.

Returns True if the given alias exists and returns False if the given alias does not exist.

CLI Example:

salt myminion boto_lambda.alias_exists myfunction myalias
salt.modules.boto_lambda.create_alias(FunctionName, Name, FunctionVersion, Description='', region=None, key=None, keyid=None, profile=None)

Given a valid config, create an alias to a function.

Returns {created: true} if the alias was created and returns {created: False} if the alias was not created.

CLI Example:

salt myminion boto_lamba.create_alias my_function my_alias $LATEST "An alias"
salt.modules.boto_lambda.create_event_source_mapping(EventSourceArn, FunctionName, StartingPosition, Enabled=True, BatchSize=100, region=None, key=None, keyid=None, profile=None)

Identifies a stream as an event source for a Lambda function. It can be either an Amazon Kinesis stream or an Amazon DynamoDB stream. AWS Lambda invokes the specified function when records are posted to the stream.

Returns {created: true} if the event source mapping was created and returns {created: False} if the event source mapping was not created.

CLI Example:

salt myminion boto_lamba.create_event_source_mapping arn::::eventsource myfunction LATEST
salt.modules.boto_lambda.create_function(FunctionName, Runtime, Role, Handler, ZipFile=None, S3Bucket=None, S3Key=None, S3ObjectVersion=None, Description='', Timeout=3, MemorySize=128, Publish=False, WaitForRole=False, RoleRetries=5, region=None, key=None, keyid=None, profile=None, VpcConfig=None, Environment=None)

New in version 2017.7.0.

Given a valid config, create a function.

Environment

The parent object that contains your environment's configuration settings. This is a dictionary of the form:

{
    'Variables': {
        'VariableName': 'VariableValue'
    }
}

Returns {'created': True} if the function was created and {created: False} if the function was not created.

CLI Example:

salt myminion boto_lamba.create_function my_function python2.7 my_role my_file.my_function my_function.zip
salt myminion boto_lamba.create_function my_function python2.7 my_role my_file.my_function salt://files/my_function.zip
salt.modules.boto_lambda.delete_alias(FunctionName, Name, region=None, key=None, keyid=None, profile=None)

Given a function name and alias name, delete the alias.

Returns {deleted: true} if the alias was deleted and returns {deleted: false} if the alias was not deleted.

CLI Example:

salt myminion boto_lambda.delete_alias myfunction myalias
salt.modules.boto_lambda.delete_event_source_mapping(UUID=None, EventSourceArn=None, FunctionName=None, region=None, key=None, keyid=None, profile=None)

Given an event source mapping ID or an event source ARN and FunctionName, delete the event source mapping

Returns {deleted: true} if the mapping was deleted and returns {deleted: false} if the mapping was not deleted.

CLI Example:

salt myminion boto_lambda.delete_event_source_mapping 260c423d-e8b5-4443-8d6a-5e91b9ecd0fa
salt.modules.boto_lambda.delete_function(FunctionName, Qualifier=None, region=None, key=None, keyid=None, profile=None)

Given a function name and optional version qualifier, delete it.

Returns {deleted: true} if the function was deleted and returns {deleted: false} if the function was not deleted.

CLI Example:

salt myminion boto_lambda.delete_function myfunction
salt.modules.boto_lambda.describe_alias(FunctionName, Name, region=None, key=None, keyid=None, profile=None)

Given a function name and alias name describe the properties of the alias.

Returns a dictionary of interesting properties.

CLI Example:

salt myminion boto_lambda.describe_alias myalias
salt.modules.boto_lambda.describe_event_source_mapping(UUID=None, EventSourceArn=None, FunctionName=None, region=None, key=None, keyid=None, profile=None)

Given an event source mapping ID or an event source ARN and FunctionName, obtain the current settings of that mapping.

Returns a dictionary of interesting properties.

CLI Example:

salt myminion boto_lambda.describe_event_source_mapping uuid
salt.modules.boto_lambda.describe_function(FunctionName, region=None, key=None, keyid=None, profile=None)

Given a function name describe its properties.

Returns a dictionary of interesting properties.

CLI Example:

salt myminion boto_lambda.describe_function myfunction
salt.modules.boto_lambda.event_source_mapping_exists(UUID=None, EventSourceArn=None, FunctionName=None, region=None, key=None, keyid=None, profile=None)

Given an event source mapping ID or an event source ARN and FunctionName, check whether the mapping exists.

Returns True if the given alias exists and returns False if the given alias does not exist.

CLI Example:

salt myminion boto_lambda.alias_exists myfunction myalias
salt.modules.boto_lambda.function_exists(FunctionName, region=None, key=None, keyid=None, profile=None)

Given a function name, check to see if the given function name exists.

Returns True if the given function exists and returns False if the given function does not exist.

CLI Example:

salt myminion boto_lambda.function_exists myfunction
salt.modules.boto_lambda.get_event_source_mapping_ids(EventSourceArn, FunctionName, region=None, key=None, keyid=None, profile=None)

Given an event source and function name, return a list of mapping IDs

CLI Example:

salt myminion boto_lambda.get_event_source_mapping_ids arn:::: myfunction
salt.modules.boto_lambda.get_permissions(FunctionName, Qualifier=None, region=None, key=None, keyid=None, profile=None)

Get resource permissions for the given lambda function

Returns dictionary of permissions, by statement ID

CLI Example:

salt myminion boto_lamba.get_permissions my_function

permissions: {...}
salt.modules.boto_lambda.list_function_versions(FunctionName, region=None, key=None, keyid=None, profile=None)

List the versions available for the given function.

Returns list of function versions

CLI Example:

versions:
  - {...}
  - {...}
salt.modules.boto_lambda.list_functions(region=None, key=None, keyid=None, profile=None)

List all Lambda functions visible in the current scope.

CLI Example:

salt myminion boto_lambda.list_functions
salt.modules.boto_lambda.remove_permission(FunctionName, StatementId, Qualifier=None, region=None, key=None, keyid=None, profile=None)

Remove a permission from a lambda function.

Returns {removed: true} if the permission was removed and returns {removed: False} if the permission was not removed.

CLI Example:

salt myminion boto_lamba.remove_permission my_function my_id
salt.modules.boto_lambda.update_alias(FunctionName, Name, FunctionVersion=None, Description=None, region=None, key=None, keyid=None, profile=None)

Update the named alias to the configuration.

Returns {updated: true} if the alias was updated and returns {updated: False} if the alias was not updated.

CLI Example:

salt myminion boto_lamba.update_alias my_lambda my_alias $LATEST
salt.modules.boto_lambda.update_event_source_mapping(UUID, FunctionName=None, Enabled=None, BatchSize=None, region=None, key=None, keyid=None, profile=None)

Update the event source mapping identified by the UUID.

Returns {updated: true} if the alias was updated and returns {updated: False} if the alias was not updated.

CLI Example:

salt myminion boto_lamba.update_event_source_mapping uuid FunctionName=new_function
salt.modules.boto_lambda.update_function_code(FunctionName, ZipFile=None, S3Bucket=None, S3Key=None, S3ObjectVersion=None, Publish=False, region=None, key=None, keyid=None, profile=None)

Upload the given code to the named lambda function.

Returns {updated: true} if the function was updated and returns {updated: False} if the function was not updated.

CLI Example:

salt myminion boto_lamba.update_function_code my_function ZipFile=function.zip
salt.modules.boto_lambda.update_function_config(FunctionName, Role=None, Handler=None, Description=None, Timeout=None, MemorySize=None, region=None, key=None, keyid=None, profile=None, VpcConfig=None, WaitForRole=False, RoleRetries=5, Environment=None)

New in version 2017.7.0.

Update the named lambda function to the configuration.

Environment

The parent object that contains your environment's configuration settings. This is a dictionary of the form:

{
    'Variables': {
        'VariableName': 'VariableValue'
    }
}

Returns {'updated': True} if the function was updated, and {'updated': False} if the function was not updated.

CLI Example:

salt myminion boto_lamba.update_function_config my_function my_role my_file.my_function "my lambda function"