Note

You are viewing the documentation for an older version of boto (boto2).

Boto3, the next version of Boto, is now stable and recommended for general use. It can be used side-by-side with Boto in the same project, so it is easy to start using Boto3 in your existing projects as well as new projects. Going forward, API updates and all new feature work will be focused on Boto3.

For more information, see the documentation for boto3.

AWS Lambda

boto.awslambda

boto.awslambda.connect_to_region(region_name, **kw_params)
boto.awslambda.regions()

Get all available regions for the AWS Lambda service. :rtype: list :return: A list of boto.regioninfo.RegionInfo

boto.awslambda.layer1

class boto.awslambda.layer1.AWSLambdaConnection(**kwargs)

AWS Lambda Overview

This is the AWS Lambda API Reference. The AWS Lambda Developer Guide provides additional information. For the service overview, go to `What is AWS Lambda`_, and for information about how the service works, go to `AWS LambdaL How it Works`_ in the AWS Lambda Developer Guide.

APIVersion = '2014-11-11'
DefaultRegionEndpoint = 'lambda.us-east-1.amazonaws.com'
DefaultRegionName = 'us-east-1'
ResponseError

alias of boto.exception.JSONResponseError

add_event_source(event_source, function_name, role, batch_size=None, parameters=None)

Identifies an Amazon Kinesis stream as the event source for an AWS Lambda function. AWS Lambda invokes the specified function when records are posted to the stream.

This is the pull model, where AWS Lambda invokes the function. For more information, go to `AWS LambdaL How it Works`_ in the AWS Lambda Developer Guide.

This association between an Amazon Kinesis stream and an AWS Lambda function is called the event source mapping. You provide the configuration information (for example, which stream to read from and which AWS Lambda function to invoke) for the event source mapping in the request body.

This operation requires permission for the iam:PassRole action for the IAM role. It also requires permission for the lambda:AddEventSource action.

Parameters:
  • event_source (string) – The Amazon Resource Name (ARN) of the Amazon Kinesis stream that is the event source. Any record added to this stream causes AWS Lambda to invoke your Lambda function. AWS Lambda POSTs the Amazon Kinesis event, containing records, to your Lambda function as JSON.
  • function_name (string) – The Lambda function to invoke when AWS Lambda detects an event on the stream.
  • role (string) – The ARN of the IAM role (invocation role) that AWS Lambda can assume to read from the stream and invoke the function.
  • batch_size (integer) – The largest number of records that AWS Lambda will give to your function in a single event. The default is 100 records.
  • parameters (map) – A map (key-value pairs) defining the configuration for AWS Lambda to use when reading the event source. Currently, AWS Lambda supports only the InitialPositionInStream key. The valid values are: “TRIM_HORIZON” and “LATEST”. The default value is “TRIM_HORIZON”. For more information, go to `ShardIteratorType`_ in the Amazon Kinesis Service API Reference.
delete_function(function_name)

Deletes the specified Lambda function code and configuration.

This operation requires permission for the lambda:DeleteFunction action.

Parameters:function_name (string) – The Lambda function to delete.
get_event_source(uuid)

Returns configuration information for the specified event source mapping (see AddEventSource).

This operation requires permission for the lambda:GetEventSource action.

Parameters:uuid (string) – The AWS Lambda assigned ID of the event source mapping.
get_function(function_name)

Returns the configuration information of the Lambda function and a presigned URL link to the .zip file you uploaded with UploadFunction so you can download the .zip file. Note that the URL is valid for up to 10 minutes. The configuration information is the same information you provided as parameters when uploading the function.

This operation requires permission for the lambda:GetFunction action.

Parameters:function_name (string) – The Lambda function name.
get_function_configuration(function_name)

Returns the configuration information of the Lambda function. This the same information you provided as parameters when uploading the function by using UploadFunction.

This operation requires permission for the lambda:GetFunctionConfiguration operation.

Parameters:function_name (string) – The name of the Lambda function for which you want to retrieve the configuration information.
invoke_async(function_name, invoke_args)

Submits an invocation request to AWS Lambda. Upon receiving the request, Lambda executes the specified function asynchronously. To see the logs generated by the Lambda function execution, see the CloudWatch logs console.

This operation requires permission for the lambda:InvokeAsync action.

Parameters:
  • function_name (string) – The Lambda function name.
  • invoke_args (blob) – JSON that you want to provide to your Lambda function as input.
list_event_sources(event_source_arn=None, function_name=None, marker=None, max_items=None)

Returns a list of event source mappings. For each mapping, the API returns configuration information (see AddEventSource). You can optionally specify filters to retrieve specific event source mappings.

This operation requires permission for the lambda:ListEventSources action.

Parameters:
  • event_source_arn (string) – The Amazon Resource Name (ARN) of the Amazon Kinesis stream.
  • function_name (string) – The name of the AWS Lambda function.
  • marker (string) – Optional string. An opaque pagination token returned from a previous ListEventSources operation. If present, specifies to continue the list from where the returning call left off.
  • max_items (integer) – Optional integer. Specifies the maximum number of event sources to return in response. This value must be greater than 0.
list_functions(marker=None, max_items=None)

Returns a list of your Lambda functions. For each function, the response includes the function configuration information. You must use GetFunction to retrieve the code for your function.

This operation requires permission for the lambda:ListFunctions action.

Parameters:
  • marker (string) – Optional string. An opaque pagination token returned from a previous ListFunctions operation. If present, indicates where to continue the listing.
  • max_items (integer) – Optional integer. Specifies the maximum number of AWS Lambda functions to return in response. This parameter value must be greater than 0.
make_request(verb, resource, headers=None, data='', expected_status=None, params=None)

Makes a request to the server, with stock multiple-retry logic.

remove_event_source(uuid)

Removes an event source mapping. This means AWS Lambda will no longer invoke the function for events in the associated source.

This operation requires permission for the lambda:RemoveEventSource action.

Parameters:uuid (string) – The event source mapping ID.
update_function_configuration(function_name, role=None, handler=None, description=None, timeout=None, memory_size=None)

Updates the configuration parameters for the specified Lambda function by using the values provided in the request. You provide only the parameters you want to change. This operation must only be used on an existing Lambda function and cannot be used to update the function’s code.

This operation requires permission for the lambda:UpdateFunctionConfiguration action.

Parameters:
  • function_name (string) – The name of the Lambda function.
  • role (string) – The Amazon Resource Name (ARN) of the IAM role that Lambda will assume when it executes your function.
  • handler (string) – The function that Lambda calls to begin executing your function. For Node.js, it is the module-name.export value in your function.
  • description (string) – A short user-defined function description. Lambda does not use this value. Assign a meaningful description as you see fit.
  • timeout (integer) – The function execution time at which Lambda should terminate the function. Because the execution time has cost implications, we recommend you set this value based on your expected execution time. The default is 3 seconds.
  • memory_size (integer) – The amount of memory, in MB, your Lambda function is given. Lambda uses this memory size to infer the amount of CPU allocated to your function. Your function use-case determines your CPU and memory requirements. For example, a database operation might need less memory compared to an image processing function. The default value is 128 MB. The value must be a multiple of 64 MB.
upload_function(function_name, function_zip, runtime, role, handler, mode, description=None, timeout=None, memory_size=None)

Creates a new Lambda function or updates an existing function. The function metadata is created from the request parameters, and the code for the function is provided by a .zip file in the request body. If the function name already exists, the existing Lambda function is updated with the new code and metadata.

This operation requires permission for the lambda:UploadFunction action.

Parameters:
  • function_name (string) – The name you want to assign to the function you are uploading. The function names appear in the console and are returned in the ListFunctions API. Function names are used to specify functions to other AWS Lambda APIs, such as InvokeAsync.
  • function_zip (blob) – A .zip file containing your packaged source code. For more information about creating a .zip file, go to `AWS LambdaL How it Works`_ in the AWS Lambda Developer Guide.
  • runtime (string) – The runtime environment for the Lambda function you are uploading. Currently, Lambda supports only “nodejs” as the runtime.
  • role (string) – The Amazon Resource Name (ARN) of the IAM role that Lambda assumes when it executes your function to access any other Amazon Web Services (AWS) resources.
  • handler (string) – The function that Lambda calls to begin execution. For Node.js, it is the module-name . export value in your function.
  • mode (string) – How the Lambda function will be invoked. Lambda supports only the “event” mode.
  • description (string) – A short, user-defined function description. Lambda does not use this value. Assign a meaningful description as you see fit.
  • timeout (integer) – The function execution time at which Lambda should terminate the function. Because the execution time has cost implications, we recommend you set this value based on your expected execution time. The default is 3 seconds.
  • memory_size (integer) – The amount of memory, in MB, your Lambda function is given. Lambda uses this memory size to infer the amount of CPU allocated to your function. Your function use-case determines your CPU and memory requirements. For example, database operation might need less memory compared to image processing function. The default value is 128 MB. The value must be a multiple of 64 MB.

boto.awslambda.exceptions

exception boto.awslambda.exceptions.InvalidParameterValueException(status, reason, body=None, *args)
exception boto.awslambda.exceptions.InvalidRequestContentException(status, reason, body=None, *args)
exception boto.awslambda.exceptions.ResourceNotFoundException(status, reason, body=None, *args)
exception boto.awslambda.exceptions.ServiceException(status, reason, body=None, *args)