boto3_lambda

Connection module for Amazon Lambda using boto3.

Renamed from boto_lambda to boto3_lambda and rewritten to use the boto3 lambda client APIs directly via saltext.boto3.utils.boto3mod. The legacy boto2 code path (object-style access, retry loops) has been removed.

depends:
  • boto3 >= 1.28.0

  • botocore >= 1.31.0

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 at:

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html

If IAM roles are not used you need to specify them either in the minion’s config file or as a profile. For example, to specify them 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

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

Added in version 1.0.0.

saltext.boto3.modules.boto3_lambda.__virtual__()[source]

Only load if boto3 is available.

saltext.boto3.modules.boto3_lambda.function_exists(FunctionName, region=None, key=None, keyid=None, profile=None)[source]

Check whether a Lambda function exists.

FunctionName (str):

The name of the Lambda function to check.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.function_exists myfunction
saltext.boto3.modules.boto3_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)[source]

Create a Lambda function.

FunctionName (str):

The name of the Lambda function to create.

Runtime (str):

The runtime environment for the Lambda function (e.g., python3.9).

Role (str):

The IAM role ARN that the Lambda function assumes when it is invoked.

Handler (str):

The function within your code that Lambda calls to begin execution.

ZipFile (str, optional):

The path to the deployment package zip file.

S3Bucket (str, optional):

The S3 bucket containing the deployment package.

S3Key (str, optional):

The S3 key of the deployment package.

S3ObjectVersion (str, optional):

The version of the S3 object containing the deployment package.

Description (str, optional):

A description of the Lambda function.

Timeout (int, optional):

The amount of time that Lambda allows a function to run before stopping it.

MemorySize (int, optional):

The amount of memory available to the function at runtime.

Publish (bool, optional):

Whether to publish a new version of the function.

WaitForRole (bool, optional):

Whether to wait for the IAM role to propagate before creating the function.

RoleRetries (int, optional):

The number of times to retry if waiting for the IAM role.

region (str, optional):

The AWS region where the Lambda function is to be created.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

VpcConfig (dict, optional):

The VPC configuration for the Lambda function.

Environment (dict, optional):

The environment variables for the Lambda function.

CLI Example:

salt myminion boto3_lambda.create_function my_function python3.9 my_role my_file.handler my_function.zip
saltext.boto3.modules.boto3_lambda.delete_function(FunctionName, Qualifier=None, region=None, key=None, keyid=None, profile=None)[source]

Delete a Lambda function.

FunctionName (str):

The name of the Lambda function to delete.

Qualifier (str, optional):

The version or alias of the function to delete.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.delete_function myfunction
saltext.boto3.modules.boto3_lambda.describe_function(FunctionName, region=None, key=None, keyid=None, profile=None)[source]

Describe the given Lambda function.

FunctionName (str):

The name of the Lambda function to describe.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.describe_function myfunction
saltext.boto3.modules.boto3_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)[source]

Update the named Lambda function configuration.

FunctionName (str):

The name of the Lambda function to update.

Role (str, optional):

The IAM role ARN that the Lambda function assumes when it is invoked.

Handler (str, optional):

The function within your code that Lambda calls to begin execution.

Description (str, optional):

A description of the Lambda function.

Timeout (int, optional):

The amount of time that Lambda allows a function to run before stopping it.

MemorySize (int, optional):

The amount of memory available to the function at runtime.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

VpcConfig (dict, optional):

The VPC configuration for the Lambda function.

WaitForRole (bool, optional):

Whether to wait for the IAM role to propagate before updating the function.

RoleRetries (int, optional):

The number of times to retry if waiting for the IAM role.

Environment (dict, optional):

The environment variables for the Lambda function.

CLI Example:

salt myminion boto3_lambda.update_function_config my_function Description="..."
saltext.boto3.modules.boto3_lambda.update_function_code(FunctionName, ZipFile=None, S3Bucket=None, S3Key=None, S3ObjectVersion=None, Publish=False, region=None, key=None, keyid=None, profile=None)[source]

Update the named Lambda function’s code.

FunctionName (str):

The name of the Lambda function to update.

ZipFile (str, optional):

The path to the deployment package zip file.

S3Bucket (str, optional):

The S3 bucket containing the deployment package.

S3Key (str, optional):

The S3 key of the deployment package.

S3ObjectVersion (str, optional):

The version of the S3 object containing the deployment package.

Publish (bool, optional):

Whether to publish a new version of the function.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.update_function_code my_function ZipFile=function.zip
saltext.boto3.modules.boto3_lambda.add_permission(FunctionName, StatementId, Action, Principal, SourceArn=None, SourceAccount=None, Qualifier=None, region=None, key=None, keyid=None, profile=None)[source]

Add a permission to a Lambda function.

FunctionName (str):

The name of the Lambda function to which the permission will be added.

StatementId (str):

A unique identifier for the statement.

Action (str):

The action that the principal is allowed to perform.

Principal (str):

The AWS service or account that is allowed to invoke the function.

SourceArn (str, optional):

The ARN of the source resource.

SourceAccount (str, optional):

The AWS account ID of the source.

Qualifier (str, optional):

The version or alias of the function.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.add_permission my_function my_id "lambda:*" s3.amazonaws.com
saltext.boto3.modules.boto3_lambda.remove_permission(FunctionName, StatementId, Qualifier=None, region=None, key=None, keyid=None, profile=None)[source]

Remove a permission from a Lambda function.

FunctionName (str):

The name of the Lambda function from which the permission will be removed.

StatementId (str):

The ID of the statement to remove.

Qualifier (str, optional):

The version or alias of the function.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.remove_permission my_function my_id
saltext.boto3.modules.boto3_lambda.get_permissions(FunctionName, Qualifier=None, region=None, key=None, keyid=None, profile=None)[source]

Get resource permissions for the given Lambda function.

FunctionName (str):

The name of the Lambda function for which to retrieve permissions.

Qualifier (str, optional):

The version or alias of the function.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.get_permissions my_function
saltext.boto3.modules.boto3_lambda.list_functions(region=None, key=None, keyid=None, profile=None)[source]

List all Lambda functions visible in the current scope.

region (str, optional):

The AWS region where the Lambda functions are located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.list_functions
saltext.boto3.modules.boto3_lambda.list_function_versions(FunctionName, region=None, key=None, keyid=None, profile=None)[source]

List the versions available for the given function.

FunctionName (str):

The name of the Lambda function for which to list versions.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.list_function_versions myfunction
saltext.boto3.modules.boto3_lambda.create_alias(FunctionName, Name, FunctionVersion, Description='', region=None, key=None, keyid=None, profile=None)[source]

Create an alias for a Lambda function.

FunctionName (str):

The name of the Lambda function for which to create an alias.

Name (str):

The name of the alias to create.

FunctionVersion (str):

The version of the Lambda function that the alias points to.

Description (str, optional):

A description for the alias.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.create_alias my_function my_alias '$LATEST'
saltext.boto3.modules.boto3_lambda.delete_alias(FunctionName, Name, region=None, key=None, keyid=None, profile=None)[source]

Delete an alias.

FunctionName (str):

The name of the Lambda function from which to delete the alias.

Name (str):

The name of the alias to delete.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.delete_alias myfunction myalias
saltext.boto3.modules.boto3_lambda.alias_exists(FunctionName, Name, region=None, key=None, keyid=None, profile=None)[source]

Check whether a Lambda alias exists.

FunctionName (str):

The name of the Lambda function for which to check the alias.

Name (str):

The name of the alias to check.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.alias_exists myfunction myalias
saltext.boto3.modules.boto3_lambda.describe_alias(FunctionName, Name, region=None, key=None, keyid=None, profile=None)[source]

Describe a Lambda alias.

FunctionName (str):

The name of the Lambda function for which to describe the alias.

Name (str):

The name of the alias to describe.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.describe_alias myfunction myalias
saltext.boto3.modules.boto3_lambda.update_alias(FunctionName, Name, FunctionVersion=None, Description=None, region=None, key=None, keyid=None, profile=None)[source]

Update a Lambda alias.

FunctionName (str):

The name of the Lambda function for which to update the alias.

Name (str):

The name of the alias to update.

FunctionVersion (str, optional):

The version of the Lambda function that the alias points to.

Description (str, optional):

A description for the alias.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.update_alias my_lambda my_alias '$LATEST'
saltext.boto3.modules.boto3_lambda.create_event_source_mapping(EventSourceArn, FunctionName, StartingPosition, Enabled=True, BatchSize=100, region=None, key=None, keyid=None, profile=None)[source]

Create an event source mapping.

EventSourceArn (str):

The ARN of the event source.

FunctionName (str):

The name of the Lambda function to associate with the event source.

StartingPosition (str):

The position in the stream where AWS Lambda should start reading.

Enabled (bool, optional):

Whether the event source mapping is enabled. Defaults to True.

BatchSize (int, optional):

The maximum number of items to retrieve in a single batch. Defaults to 100.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.create_event_source_mapping arn::::eventsource myfunction LATEST
saltext.boto3.modules.boto3_lambda.get_event_source_mapping_ids(EventSourceArn, FunctionName, region=None, key=None, keyid=None, profile=None)[source]

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

EventSourceArn (str):

The ARN of the event source.

FunctionName (str):

The name of the Lambda function associated with the event source.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.get_event_source_mapping_ids arn:::: myfunction
saltext.boto3.modules.boto3_lambda.delete_event_source_mapping(UUID=None, EventSourceArn=None, FunctionName=None, region=None, key=None, keyid=None, profile=None)[source]

Delete an event source mapping.

EventSourceArn (str):

The ARN of the event source.

FunctionName (str):

The name of the Lambda function associated with the event source.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.delete_event_source_mapping 260c423d-...
saltext.boto3.modules.boto3_lambda.event_source_mapping_exists(UUID=None, EventSourceArn=None, FunctionName=None, region=None, key=None, keyid=None, profile=None)[source]

Check whether an event source mapping exists.

EventSourceArn (str):

The ARN of the event source.

FunctionName (str):

The name of the Lambda function associated with the event source.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.event_source_mapping_exists uuid
saltext.boto3.modules.boto3_lambda.describe_event_source_mapping(UUID=None, EventSourceArn=None, FunctionName=None, region=None, key=None, keyid=None, profile=None)[source]

Describe an event source mapping.

EventSourceArn (str):

The ARN of the event source.

FunctionName (str):

The name of the Lambda function associated with the event source.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.describe_event_source_mapping uuid
saltext.boto3.modules.boto3_lambda.update_event_source_mapping(UUID, FunctionName=None, Enabled=None, BatchSize=None, region=None, key=None, keyid=None, profile=None)[source]

Update an event source mapping.

UUID (str):

The identifier of the event source mapping.

FunctionName (str, optional):

The name of the Lambda function associated with the event source.

Enabled (bool, optional):

Whether the event source mapping is enabled.

BatchSize (int, optional):

The maximum number of items to retrieve in a single batch.

region (str, optional):

The AWS region where the Lambda function is located.

key (str, optional):

The AWS secret access key.

keyid (str, optional):

The AWS access key ID.

profile (str, optional):

The profile to use for AWS credentials.

CLI Example:

salt myminion boto3_lambda.update_event_source_mapping uuid FunctionName=new_function