Lambda

Table of Contents

Client

class Lambda.Client

A low-level client representing AWS Lambda:

client = session.create_client('lambda')

These are the available methods:

add_permission(**kwargs)

Adds a permission to the access policy associated with the specified AWS Lambda function. In a "push event" model, the access policy attached to the Lambda function grants Amazon S3 or a user application permission for the Lambda lambda:Invoke action. For information about the push model, see AWS Lambda: How it Works . Each Lambda function has one access policy associated with it. You can use the AddPermission API to add a permission to the policy. You have one access policy but it can have multiple permission statements.

This operation requires permission for the lambda:AddPermission action.

Request Syntax

response = client.add_permission(
    FunctionName='string',
    StatementId='string',
    Action='string',
    Principal='string',
    SourceArn='string',
    SourceAccount='string'
)
Parameters:
  • FunctionName (string) --

    [REQUIRED]

    Name of the Lambda function whose access policy you are updating by adding a new permission.

    You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length.

  • StatementId (string) --

    [REQUIRED]

    A unique statement identifier.

  • Action (string) --

    [REQUIRED]

    The AWS Lambda action you want to allow in this statement. Each Lambda action is a string starting with "lambda:" followed by the API name (see Operations ). For example, "lambda:CreateFunction". You can use wildcard ("lambda:*") to grant permission for all AWS Lambda actions.

  • Principal (string) --

    [REQUIRED]

    The principal who is getting this permission. It can be Amazon S3 service Principal ("s3.amazonaws.com") if you want Amazon S3 to invoke the function, an AWS account ID if you are granting cross-account permission, or any valid AWS service principal such as "sns.amazonaws.com". For example, you might want to allow a custom application in another AWS account to push events to AWS Lambda by invoking your function.

  • SourceArn (string) --

    This is optional; however, when granting Amazon S3 permission to invoke your function, you should specify this field with the bucket Amazon Resource Name (ARN) as its value. This ensures that only events generated from the specified bucket can invoke the function.

    Warning

    If you add a permission for the Amazon S3 principal without providing the source ARN, any AWS account that creates a mapping to your function ARN can send events to invoke your Lambda function from Amazon S3.

  • SourceAccount (string) -- The AWS account ID (without a hyphen) of the source owner. For example, if the SourceArn identifies a bucket, then this is the bucket owner's account ID. You can use this additional condition to ensure the bucket you specify is owned by a specific account (it is possible the bucket owner deleted the bucket and some other AWS account created the bucket). You can also use this condition to specify all sources (that is, you don't specify the SourceArn ) owned by a specific account.
Return type:

dict

Returns:

Response Syntax

{
    'Statement': 'string'
}

Response Structure

  • (dict) --

    • Statement (string) --

      The permission statement you specified in the request. The response returns the same as a string using "" as an escape character in the JSON.

can_paginate(operation_name)

Check if an operation can be paginated.

Parameters:operation_name (string) -- The operation name. This is the same name as the method name on the client. For example, if the method name is create_foo, and you'd normally invoke the operation as client.create_foo(**kwargs), if the create_foo operation can be paginated, you can use the call client.get_paginator("create_foo").
Returns:True if the operation can be paginated, False otherwise.
create_event_source_mapping(**kwargs)

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.

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

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

Each event source, such as an Amazon Kinesis or a DynamoDB stream, can be associated with multiple AWS Lambda function. A given Lambda function can be associated with multiple AWS event sources.

This operation requires permission for the lambda:CreateEventSourceMapping action.

Request Syntax

response = client.create_event_source_mapping(
    EventSourceArn='string',
    FunctionName='string',
    Enabled=True|False,
    BatchSize=123,
    StartingPosition='TRIM_HORIZON'|'LATEST'
)
Parameters:
  • EventSourceArn (string) --

    [REQUIRED]

    The Amazon Resource Name (ARN) of the Amazon Kinesis or the Amazon DynamoDB stream that is the event source. Any record added to this stream could cause AWS Lambda to invoke your Lambda function, it depends on the BatchSize . AWS Lambda POSTs the Amazon Kinesis event, containing records, to your Lambda function as JSON.

  • FunctionName (string) --

    [REQUIRED]

    The Lambda function to invoke when AWS Lambda detects an event on the stream.

    You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length.

  • Enabled (boolean) -- Indicates whether AWS Lambda should begin polling the event source, the default is not enabled.
  • BatchSize (integer) -- The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function. Your function receives an event with all the retrieved records. The default is 100 records.
  • StartingPosition (string) --

    [REQUIRED]

    The position in the stream where AWS Lambda should start reading. For more information, go to ShardIteratorType in the Amazon Kinesis API Reference .

Return type:

dict

Returns:

Response Syntax

{
    'UUID': 'string',
    'BatchSize': 123,
    'EventSourceArn': 'string',
    'FunctionArn': 'string',
    'LastModified': datetime(2015, 1, 1),
    'LastProcessingResult': 'string',
    'State': 'string',
    'StateTransitionReason': 'string'
}

Response Structure

  • (dict) --

    Describes mapping between an Amazon Kinesis stream and a Lambda function.

    • UUID (string) --

      The AWS Lambda assigned opaque identifier for the mapping.

    • BatchSize (integer) --

      The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function. Your function receives an event with all the retrieved records.

    • EventSourceArn (string) --

      The Amazon Resource Name (ARN) of the Amazon Kinesis stream that is the source of events.

    • FunctionArn (string) --

      The Lambda function to invoke when AWS Lambda detects an event on the stream.

    • LastModified (datetime) --

      The UTC time string indicating the last time the event mapping was updated.

    • LastProcessingResult (string) --

      The result of the last AWS Lambda invocation of your Lambda function.

    • State (string) --

      The state of the event source mapping. It can be "Creating", "Enabled", "Disabled", "Enabling", "Disabling", "Updating", or "Deleting".

    • StateTransitionReason (string) --

      The reason the event source mapping is in its current state. It is either user-requested or an AWS Lambda-initiated state transition.

create_function(**kwargs)

Creates a new Lambda 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 operation will fail. Note that the function name is case-sensitive.

This operation requires permission for the lambda:CreateFunction action.

Request Syntax

response = client.create_function(
    FunctionName='string',
    Runtime='nodejs'|'java8',
    Role='string',
    Handler='string',
    Description='string',
    Timeout=123,
    MemorySize=123,
    Code={
        'ZipFile': b'bytes',
        'S3Bucket': 'string',
        'S3Key': 'string',
        'S3ObjectVersion': 'string'
    }
)
Parameters:
  • FunctionName (string) --

    [REQUIRED]

    The name you want to assign to the function you are uploading. You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length. 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 Invoke .

  • Runtime (string) --

    [REQUIRED]

    The runtime environment for the Lambda function you are uploading. Currently, Lambda supports "java" and "nodejs" as the runtime.

  • Role (string) --

    [REQUIRED]

    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. For more information, see AWS Lambda: How it Works

  • Handler (string) --

    [REQUIRED]

    The function within your code that Lambda calls to begin execution. For Node.js, it is the module-name .*export* value in your function. For Java, it can be package.class-name::handler or package.class-name . For more information, see Lambda Function Handler (Java) .

  • 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.
  • MemorySize (integer) -- The amount of memory, in MB, your Lambda function is given. Lambda uses this memory size to infer the amount of CPU and memory 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.
  • Code (dict) --

    [REQUIRED]

    The code for the Lambda function.

    • ZipFile (bytes) --

      A base64-encoded .zip file containing your deployment package. For more information about creating a .zip file, go to Execution Permissions in the AWS Lambda Developer Guide .

    • S3Bucket (string) --

      Amazon S3 bucket name where the .zip file containing your deployment package is stored. This bucket must reside in the same AWS region where you are creating the Lambda function.

    • S3Key (string) --

      The Amazon S3 object (the deployment package) key name you want to upload.

    • S3ObjectVersion (string) --

      The Amazon S3 object (the deployment package) version you want to upload.

Return type:

dict

Returns:

Response Syntax

{
    'FunctionName': 'string',
    'FunctionArn': 'string',
    'Runtime': 'nodejs'|'java8',
    'Role': 'string',
    'Handler': 'string',
    'CodeSize': 123,
    'Description': 'string',
    'Timeout': 123,
    'MemorySize': 123,
    'LastModified': 'string'
}

Response Structure

  • (dict) --

    A complex type that describes function metadata.

    • FunctionName (string) --

      The name of the function.

    • FunctionArn (string) --

      The Amazon Resource Name (ARN) assigned to the function.

    • Runtime (string) --

      The runtime environment for the Lambda function.

    • 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 Lambda calls to begin executing your function.

    • CodeSize (integer) --

      The size, in bytes, of the function .zip file you uploaded.

    • Description (string) --

      The user-provided description.

    • 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.

    • MemorySize (integer) --

      The memory size, in MB, you configured for the function. Must be a multiple of 64 MB.

    • LastModified (string) --

      The timestamp of the last time you updated the function.

delete_event_source_mapping(**kwargs)

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:DeleteEventSourceMapping action.

Request Syntax

response = client.delete_event_source_mapping(
    UUID='string'
)
Parameters:UUID (string) --

[REQUIRED]

The event source mapping ID.

Return type:dict
Returns:Response Syntax
{
    'UUID': 'string',
    'BatchSize': 123,
    'EventSourceArn': 'string',
    'FunctionArn': 'string',
    'LastModified': datetime(2015, 1, 1),
    'LastProcessingResult': 'string',
    'State': 'string',
    'StateTransitionReason': 'string'
}

Response Structure

  • (dict) --

    Describes mapping between an Amazon Kinesis stream and a Lambda function.

    • UUID (string) --

      The AWS Lambda assigned opaque identifier for the mapping.

    • BatchSize (integer) --

      The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function. Your function receives an event with all the retrieved records.

    • EventSourceArn (string) --

      The Amazon Resource Name (ARN) of the Amazon Kinesis stream that is the source of events.

    • FunctionArn (string) --

      The Lambda function to invoke when AWS Lambda detects an event on the stream.

    • LastModified (datetime) --

      The UTC time string indicating the last time the event mapping was updated.

    • LastProcessingResult (string) --

      The result of the last AWS Lambda invocation of your Lambda function.

    • State (string) --

      The state of the event source mapping. It can be "Creating", "Enabled", "Disabled", "Enabling", "Disabling", "Updating", or "Deleting".

    • StateTransitionReason (string) --

      The reason the event source mapping is in its current state. It is either user-requested or an AWS Lambda-initiated state transition.

delete_function(**kwargs)

Deletes the specified Lambda function code and configuration.

When you delete a function the associated access policy is also deleted. You will need to delete the event source mappings explicitly.

This operation requires permission for the lambda:DeleteFunction action.

Request Syntax

response = client.delete_function(
    FunctionName='string'
)
Parameters:FunctionName (string) --

[REQUIRED]

The Lambda function to delete.

You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length.

Returns:None
generate_presigned_url(ClientMethod, Params=None, ExpiresIn=3600, HttpMethod=None)

Generate a presigned url given a client, its method, and arguments

Parameters:
  • ClientMethod (string) -- The client method to presign for
  • Params (dict) -- The parameters normally passed to ClientMethod.
  • ExpiresIn (int) -- The number of seconds the presigned url is valid for. By default it expires in an hour (3600 seconds)
  • HttpMethod (string) -- The http method to use on the generated url. By default, the http method is whatever is used in the method's model.
Returns:

The presigned url

get_event_source_mapping(**kwargs)

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

This operation requires permission for the lambda:GetEventSourceMapping action.

Request Syntax

response = client.get_event_source_mapping(
    UUID='string'
)
Parameters:UUID (string) --

[REQUIRED]

The AWS Lambda assigned ID of the event source mapping.

Return type:dict
Returns:Response Syntax
{
    'UUID': 'string',
    'BatchSize': 123,
    'EventSourceArn': 'string',
    'FunctionArn': 'string',
    'LastModified': datetime(2015, 1, 1),
    'LastProcessingResult': 'string',
    'State': 'string',
    'StateTransitionReason': 'string'
}

Response Structure

  • (dict) --

    Describes mapping between an Amazon Kinesis stream and a Lambda function.

    • UUID (string) --

      The AWS Lambda assigned opaque identifier for the mapping.

    • BatchSize (integer) --

      The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function. Your function receives an event with all the retrieved records.

    • EventSourceArn (string) --

      The Amazon Resource Name (ARN) of the Amazon Kinesis stream that is the source of events.

    • FunctionArn (string) --

      The Lambda function to invoke when AWS Lambda detects an event on the stream.

    • LastModified (datetime) --

      The UTC time string indicating the last time the event mapping was updated.

    • LastProcessingResult (string) --

      The result of the last AWS Lambda invocation of your Lambda function.

    • State (string) --

      The state of the event source mapping. It can be "Creating", "Enabled", "Disabled", "Enabling", "Disabling", "Updating", or "Deleting".

    • StateTransitionReason (string) --

      The reason the event source mapping is in its current state. It is either user-requested or an AWS Lambda-initiated state transition.

get_function(**kwargs)

Returns the configuration information of the Lambda function and a presigned URL link to the .zip file you uploaded with CreateFunction 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.

Request Syntax

response = client.get_function(
    FunctionName='string'
)
Parameters:FunctionName (string) --

[REQUIRED]

The Lambda function name.

You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length.

Return type:dict
Returns:Response Syntax
{
    'Configuration': {
        'FunctionName': 'string',
        'FunctionArn': 'string',
        'Runtime': 'nodejs'|'java8',
        'Role': 'string',
        'Handler': 'string',
        'CodeSize': 123,
        'Description': 'string',
        'Timeout': 123,
        'MemorySize': 123,
        'LastModified': 'string'
    },
    'Code': {
        'RepositoryType': 'string',
        'Location': 'string'
    }
}

Response Structure

  • (dict) --

    This response contains the object for the Lambda function location (see API_FunctionCodeLocation

    • Configuration (dict) --

      A complex type that describes function metadata.

      • FunctionName (string) --

        The name of the function.

      • FunctionArn (string) --

        The Amazon Resource Name (ARN) assigned to the function.

      • Runtime (string) --

        The runtime environment for the Lambda function.

      • 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 Lambda calls to begin executing your function.

      • CodeSize (integer) --

        The size, in bytes, of the function .zip file you uploaded.

      • Description (string) --

        The user-provided description.

      • 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.

      • MemorySize (integer) --

        The memory size, in MB, you configured for the function. Must be a multiple of 64 MB.

      • LastModified (string) --

        The timestamp of the last time you updated the function.

    • Code (dict) --

      The object for the Lambda function location.

      • RepositoryType (string) --

        The repository from which you can download the function.

      • Location (string) --

        The presigned URL you can use to download the function's .zip file that you previously uploaded. The URL is valid for up to 10 minutes.

get_function_configuration(**kwargs)

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

This operation requires permission for the lambda:GetFunctionConfiguration operation.

Request Syntax

response = client.get_function_configuration(
    FunctionName='string'
)
Parameters:FunctionName (string) --

[REQUIRED]

The name of the Lambda function for which you want to retrieve the configuration information.

You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length.

Return type:dict
Returns:Response Syntax
{
    'FunctionName': 'string',
    'FunctionArn': 'string',
    'Runtime': 'nodejs'|'java8',
    'Role': 'string',
    'Handler': 'string',
    'CodeSize': 123,
    'Description': 'string',
    'Timeout': 123,
    'MemorySize': 123,
    'LastModified': 'string'
}

Response Structure

  • (dict) --

    A complex type that describes function metadata.

    • FunctionName (string) --

      The name of the function.

    • FunctionArn (string) --

      The Amazon Resource Name (ARN) assigned to the function.

    • Runtime (string) --

      The runtime environment for the Lambda function.

    • 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 Lambda calls to begin executing your function.

    • CodeSize (integer) --

      The size, in bytes, of the function .zip file you uploaded.

    • Description (string) --

      The user-provided description.

    • 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.

    • MemorySize (integer) --

      The memory size, in MB, you configured for the function. Must be a multiple of 64 MB.

    • LastModified (string) --

      The timestamp of the last time you updated the function.

get_paginator(operation_name)

Create a paginator for an operation.

Parameters:operation_name (string) -- The operation name. This is the same name as the method name on the client. For example, if the method name is create_foo, and you'd normally invoke the operation as client.create_foo(**kwargs), if the create_foo operation can be paginated, you can use the call client.get_paginator("create_foo").
Raises OperationNotPageableError:
 Raised if the operation is not pageable. You can use the client.can_paginate method to check if an operation is pageable.
Return type:L{botocore.paginate.Paginator}
Returns:A paginator object.
get_policy(**kwargs)

Returns the access policy, containing a list of permissions granted via the AddPermission API, associated with the specified bucket.

You need permission for the lambda:GetPolicy action.

Request Syntax

response = client.get_policy(
    FunctionName='string'
)
Parameters:FunctionName (string) --

[REQUIRED]

Function name whose access policy you want to retrieve.

You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length.

Return type:dict
Returns:Response Syntax
{
    'Policy': 'string'
}

Response Structure

  • (dict) --
    • Policy (string) --

      The access policy associated with the specified function. The response returns the same as a string using "" as an escape character in the JSON.

get_waiter(waiter_name)
invoke(**kwargs)

Invokes a specified Lambda function.

This operation requires permission for the lambda:InvokeFunction action.

Request Syntax

response = client.invoke(
    FunctionName='string',
    InvocationType='Event'|'RequestResponse'|'DryRun',
    LogType='None'|'Tail',
    ClientContext='string',
    Payload=b'bytes'
)
Parameters:
  • FunctionName (string) --

    [REQUIRED]

    The Lambda function name.

    You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length.

  • InvocationType (string) -- By default, the Invoke API assumes "RequestResponse" invocation type. You can optionally request asynchronous execution by specifying "Event" as the InvocationType . You can also use this parameter to request AWS Lambda to not execute the function but do some verification, such as if the caller is authorized to invoke the function and if the inputs are valid. You request this by specifying "DryRun" as the InvocationType . This is useful in a cross-account scenario when you want to verify access to a function without running it.
  • LogType (string) -- You can set this optional parameter to "Tail" in the request only if you specify the InvocationType parameter with value "RequestResponse". In this case, AWS Lambda returns the base64-encoded last 4 KB of log data produced by your Lambda function in the x-amz-log-results header.
  • ClientContext (string) --

    Using the ClientContext you can pass client-specific information to the Lambda function you are invoking. You can then process the client information in your Lambda function as you choose through the context variable. For an example of a ClientContext JSON, go to PutEvents in the Amazon Mobile Analytics API Reference and User Guide .

    The ClientContext JSON must be base64-encoded.

  • Payload (bytes) -- JSON that you want to provide to your Lambda function as input.
Return type:

dict

Returns:

Response Syntax

{
    'StatusCode': 123,
    'FunctionError': 'string',
    'LogResult': 'string',
    'Payload': b'bytes'
}

Response Structure

  • (dict) --

    Upon success, returns an empty response. Otherwise, throws an exception.

    • StatusCode (integer) --

      The HTTP status code will be in the 200 range for successful request. For the "RequestResonse" invocation type this status code will be 200. For the "Event" invocation type this status code will be 202. For the "DryRun" invocation type the status code will be 204.

    • FunctionError (string) --

      Indicates whether an error occurred while executing the Lambda function. If an error occurred this field will have one of two values; Handled or Unhandled . Handled errors are errors that are reported by the function while the Unhandled errors are those detected and reported by AWS Lambda. Unhandled errors include out of memory errors and function timeouts. For information about how to report an Handled error, see Programming Model .

    • LogResult (string) --

      It is the base64-encoded logs for the Lambda function invocation. This is present only if the invocation type is "RequestResponse" and the logs were requested.

    • Payload (bytes) --

      It is the JSON representation of the object returned by the Lambda function. In This is present only if the invocation type is "RequestResponse".

      In the event of a function error this field contains a message describing the error. For the Handled errors the Lambda function will report this message. For Unhandled errors AWS Lambda reports the message.

invoke_async(**kwargs)

Warning

This API is deprecated. We recommend you use Invoke API (see Invoke ).

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:InvokeFunction action.

Request Syntax

response = client.invoke_async(
    FunctionName='string',
    InvokeArgs=b'bytes'
)
Parameters:
  • FunctionName (string) --

    [REQUIRED]

    The Lambda function name.

  • InvokeArgs (bytes) --

    [REQUIRED]

    JSON that you want to provide to your Lambda function as input.

Return type:

dict

Returns:

Response Syntax

{
    'Status': 123
}

Response Structure

  • (dict) --

    Upon success, it returns empty response. Otherwise, throws an exception.

    • Status (integer) --

      It will be 202 upon success.

list_event_source_mappings(**kwargs)

Returns a list of event source mappings you created using the CreateEventSourceMapping (see CreateEventSourceMapping ), where you identify a stream as an event source. This list does not include Amazon S3 event sources.

For each mapping, the API returns configuration information. You can optionally specify filters to retrieve specific event source mappings.

This operation requires permission for the lambda:ListEventSourceMappings action.

Request Syntax

response = client.list_event_source_mappings(
    EventSourceArn='string',
    FunctionName='string',
    Marker='string',
    MaxItems=123
)
Parameters:
  • EventSourceArn (string) -- The Amazon Resource Name (ARN) of the Amazon Kinesis stream.
  • FunctionName (string) --

    The name of the Lambda function.

    You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length.

  • Marker (string) -- Optional string. An opaque pagination token returned from a previous ListEventSourceMappings operation. If present, specifies to continue the list from where the returning call left off.
  • MaxItems (integer) -- Optional integer. Specifies the maximum number of event sources to return in response. This value must be greater than 0.
Return type:

dict

Returns:

Response Syntax

{
    'NextMarker': 'string',
    'EventSourceMappings': [
        {
            'UUID': 'string',
            'BatchSize': 123,
            'EventSourceArn': 'string',
            'FunctionArn': 'string',
            'LastModified': datetime(2015, 1, 1),
            'LastProcessingResult': 'string',
            'State': 'string',
            'StateTransitionReason': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    Contains a list of event sources (see API_EventSourceMappingConfiguration )

    • NextMarker (string) --

      A string, present if there are more event source mappings.

    • EventSourceMappings (list) --

      An array of EventSourceMappingConfiguration objects.

      • (dict) --

        Describes mapping between an Amazon Kinesis stream and a Lambda function.

        • UUID (string) --

          The AWS Lambda assigned opaque identifier for the mapping.

        • BatchSize (integer) --

          The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function. Your function receives an event with all the retrieved records.

        • EventSourceArn (string) --

          The Amazon Resource Name (ARN) of the Amazon Kinesis stream that is the source of events.

        • FunctionArn (string) --

          The Lambda function to invoke when AWS Lambda detects an event on the stream.

        • LastModified (datetime) --

          The UTC time string indicating the last time the event mapping was updated.

        • LastProcessingResult (string) --

          The result of the last AWS Lambda invocation of your Lambda function.

        • State (string) --

          The state of the event source mapping. It can be "Creating", "Enabled", "Disabled", "Enabling", "Disabling", "Updating", or "Deleting".

        • StateTransitionReason (string) --

          The reason the event source mapping is in its current state. It is either user-requested or an AWS Lambda-initiated state transition.

list_functions(**kwargs)

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.

Request Syntax

response = client.list_functions(
    Marker='string',
    MaxItems=123
)
Parameters:
  • Marker (string) -- Optional string. An opaque pagination token returned from a previous ListFunctions operation. If present, indicates where to continue the listing.
  • MaxItems (integer) -- Optional integer. Specifies the maximum number of AWS Lambda functions to return in response. This parameter value must be greater than 0.
Return type:

dict

Returns:

Response Syntax

{
    'NextMarker': 'string',
    'Functions': [
        {
            'FunctionName': 'string',
            'FunctionArn': 'string',
            'Runtime': 'nodejs'|'java8',
            'Role': 'string',
            'Handler': 'string',
            'CodeSize': 123,
            'Description': 'string',
            'Timeout': 123,
            'MemorySize': 123,
            'LastModified': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    Contains a list of AWS Lambda function configurations (see FunctionConfiguration .

    • NextMarker (string) --

      A string, present if there are more functions.

    • Functions (list) --

      A list of Lambda functions.

      • (dict) --

        A complex type that describes function metadata.

        • FunctionName (string) --

          The name of the function.

        • FunctionArn (string) --

          The Amazon Resource Name (ARN) assigned to the function.

        • Runtime (string) --

          The runtime environment for the Lambda function.

        • 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 Lambda calls to begin executing your function.

        • CodeSize (integer) --

          The size, in bytes, of the function .zip file you uploaded.

        • Description (string) --

          The user-provided description.

        • 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.

        • MemorySize (integer) --

          The memory size, in MB, you configured for the function. Must be a multiple of 64 MB.

        • LastModified (string) --

          The timestamp of the last time you updated the function.

remove_permission(**kwargs)

You can remove individual permissions from an access policy associated with a Lambda function by providing a Statement ID.

Note that removal of a permission will cause an active event source to lose permission to the function.

You need permission for the lambda:RemovePermission action.

Request Syntax

response = client.remove_permission(
    FunctionName='string',
    StatementId='string'
)
Parameters:
  • FunctionName (string) --

    [REQUIRED]

    Lambda function whose access policy you want to remove a permission from.

    You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length.

  • StatementId (string) --

    [REQUIRED]

    Statement ID of the permission to remove.

Returns:

None

update_event_source_mapping(**kwargs)

You can update an event source mapping. This is useful if you want to change the parameters of the existing mapping without losing your position in the stream. You can change which function will receive the stream records, but to change the stream itself, you must create a new mapping.

This operation requires permission for the lambda:UpdateEventSourceMapping action.

Request Syntax

response = client.update_event_source_mapping(
    UUID='string',
    FunctionName='string',
    Enabled=True|False,
    BatchSize=123
)
Parameters:
  • UUID (string) --

    [REQUIRED]

    The event source mapping identifier.

  • FunctionName (string) --

    The Lambda function to which you want the stream records sent.

    You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length.

  • Enabled (boolean) -- Specifies whether AWS Lambda should actively poll the stream or not. If disabled, AWS Lambda will not poll the stream.
  • BatchSize (integer) -- The maximum number of stream records that can be sent to your Lambda function for a single invocation.
Return type:

dict

Returns:

Response Syntax

{
    'UUID': 'string',
    'BatchSize': 123,
    'EventSourceArn': 'string',
    'FunctionArn': 'string',
    'LastModified': datetime(2015, 1, 1),
    'LastProcessingResult': 'string',
    'State': 'string',
    'StateTransitionReason': 'string'
}

Response Structure

  • (dict) --

    Describes mapping between an Amazon Kinesis stream and a Lambda function.

    • UUID (string) --

      The AWS Lambda assigned opaque identifier for the mapping.

    • BatchSize (integer) --

      The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function. Your function receives an event with all the retrieved records.

    • EventSourceArn (string) --

      The Amazon Resource Name (ARN) of the Amazon Kinesis stream that is the source of events.

    • FunctionArn (string) --

      The Lambda function to invoke when AWS Lambda detects an event on the stream.

    • LastModified (datetime) --

      The UTC time string indicating the last time the event mapping was updated.

    • LastProcessingResult (string) --

      The result of the last AWS Lambda invocation of your Lambda function.

    • State (string) --

      The state of the event source mapping. It can be "Creating", "Enabled", "Disabled", "Enabling", "Disabling", "Updating", or "Deleting".

    • StateTransitionReason (string) --

      The reason the event source mapping is in its current state. It is either user-requested or an AWS Lambda-initiated state transition.

update_function_code(**kwargs)

Updates the code for the specified Lambda function. This operation must only be used on an existing Lambda function and cannot be used to update the function configuration.

This operation requires permission for the lambda:UpdateFunctionCode action.

Request Syntax

response = client.update_function_code(
    FunctionName='string',
    ZipFile=b'bytes',
    S3Bucket='string',
    S3Key='string',
    S3ObjectVersion='string'
)
Parameters:
  • FunctionName (string) --

    [REQUIRED]

    The existing Lambda function name whose code you want to replace.

    You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length.

  • ZipFile (bytes) -- Based64-encoded .zip file containing your packaged source code.
  • S3Bucket (string) -- Amazon S3 bucket name where the .zip file containing your deployment package is stored. This bucket must reside in the same AWS region where you are creating the Lambda function.
  • S3Key (string) -- The Amazon S3 object (the deployment package) key name you want to upload.
  • S3ObjectVersion (string) -- The Amazon S3 object (the deployment package) version you want to upload.
Return type:

dict

Returns:

Response Syntax

{
    'FunctionName': 'string',
    'FunctionArn': 'string',
    'Runtime': 'nodejs'|'java8',
    'Role': 'string',
    'Handler': 'string',
    'CodeSize': 123,
    'Description': 'string',
    'Timeout': 123,
    'MemorySize': 123,
    'LastModified': 'string'
}

Response Structure

  • (dict) --

    A complex type that describes function metadata.

    • FunctionName (string) --

      The name of the function.

    • FunctionArn (string) --

      The Amazon Resource Name (ARN) assigned to the function.

    • Runtime (string) --

      The runtime environment for the Lambda function.

    • 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 Lambda calls to begin executing your function.

    • CodeSize (integer) --

      The size, in bytes, of the function .zip file you uploaded.

    • Description (string) --

      The user-provided description.

    • 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.

    • MemorySize (integer) --

      The memory size, in MB, you configured for the function. Must be a multiple of 64 MB.

    • LastModified (string) --

      The timestamp of the last time you updated the function.

update_function_configuration(**kwargs)

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.

Request Syntax

response = client.update_function_configuration(
    FunctionName='string',
    Role='string',
    Handler='string',
    Description='string',
    Timeout=123,
    MemorySize=123
)
Parameters:
  • FunctionName (string) --

    [REQUIRED]

    The name of the Lambda function.

    You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length.

  • 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. AWS Lambda does not use this value. Assign a meaningful description as you see fit.
  • Timeout (integer) -- The function execution time at which AWS 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.
  • MemorySize (integer) -- The amount of memory, in MB, your Lambda function is given. AWS 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.
Return type:

dict

Returns:

Response Syntax

{
    'FunctionName': 'string',
    'FunctionArn': 'string',
    'Runtime': 'nodejs'|'java8',
    'Role': 'string',
    'Handler': 'string',
    'CodeSize': 123,
    'Description': 'string',
    'Timeout': 123,
    'MemorySize': 123,
    'LastModified': 'string'
}

Response Structure

  • (dict) --

    A complex type that describes function metadata.

    • FunctionName (string) --

      The name of the function.

    • FunctionArn (string) --

      The Amazon Resource Name (ARN) assigned to the function.

    • Runtime (string) --

      The runtime environment for the Lambda function.

    • 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 Lambda calls to begin executing your function.

    • CodeSize (integer) --

      The size, in bytes, of the function .zip file you uploaded.

    • Description (string) --

      The user-provided description.

    • 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.

    • MemorySize (integer) --

      The memory size, in MB, you configured for the function. Must be a multiple of 64 MB.

    • LastModified (string) --

      The timestamp of the last time you updated the function.

Paginators

The available paginators are:

class Lambda.Paginator.list_event_source_mappings
paginator = client.get_paginator('list_event_source_mappings')
paginate(**kwargs)

Creates an iterator that will paginate through responses from Lambda.Client.list_event_source_mappings().

Request Syntax

response_iterator = paginator.paginate(
    EventSourceArn='string',
    FunctionName='string',
    PaginationConfig={
        'MaxItems': 123,
        'PageSize': 123,
        'StartingToken': 'string'
    }
)
Parameters:
  • EventSourceArn (string) -- The Amazon Resource Name (ARN) of the Amazon Kinesis stream.
  • FunctionName (string) --

    The name of the Lambda function.

    You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length.

  • PaginationConfig (dict) --

    A dictionary that provides parameters to control pagination.

    • MaxItems (integer) --

      The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken will be provided in the output that you can use to resume pagination.

    • PageSize (integer) --

      The size of each page.

    • StartingToken (string) --

      A token to specify where to start paginating. This is the NextToken from a previous response.

Return type:

dict

Returns:

Response Syntax

{
    'EventSourceMappings': [
        {
            'UUID': 'string',
            'BatchSize': 123,
            'EventSourceArn': 'string',
            'FunctionArn': 'string',
            'LastModified': datetime(2015, 1, 1),
            'LastProcessingResult': 'string',
            'State': 'string',
            'StateTransitionReason': 'string'
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    Contains a list of event sources (see API_EventSourceMappingConfiguration )

    • EventSourceMappings (list) --

      An array of EventSourceMappingConfiguration objects.

      • (dict) --

        Describes mapping between an Amazon Kinesis stream and a Lambda function.

        • UUID (string) --

          The AWS Lambda assigned opaque identifier for the mapping.

        • BatchSize (integer) --

          The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function. Your function receives an event with all the retrieved records.

        • EventSourceArn (string) --

          The Amazon Resource Name (ARN) of the Amazon Kinesis stream that is the source of events.

        • FunctionArn (string) --

          The Lambda function to invoke when AWS Lambda detects an event on the stream.

        • LastModified (datetime) --

          The UTC time string indicating the last time the event mapping was updated.

        • LastProcessingResult (string) --

          The result of the last AWS Lambda invocation of your Lambda function.

        • State (string) --

          The state of the event source mapping. It can be "Creating", "Enabled", "Disabled", "Enabling", "Disabling", "Updating", or "Deleting".

        • StateTransitionReason (string) --

          The reason the event source mapping is in its current state. It is either user-requested or an AWS Lambda-initiated state transition.

    • NextToken (string) --

      A token to resume pagination.

class Lambda.Paginator.list_functions
paginator = client.get_paginator('list_functions')
paginate(**kwargs)

Creates an iterator that will paginate through responses from Lambda.Client.list_functions().

Request Syntax

response_iterator = paginator.paginate(
    PaginationConfig={
        'MaxItems': 123,
        'PageSize': 123,
        'StartingToken': 'string'
    }
)
Parameters:PaginationConfig (dict) --

A dictionary that provides parameters to control pagination.

  • MaxItems (integer) --

    The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken will be provided in the output that you can use to resume pagination.

  • PageSize (integer) --

    The size of each page.

  • StartingToken (string) --

    A token to specify where to start paginating. This is the NextToken from a previous response.

Return type:dict
Returns:Response Syntax
{
    'Functions': [
        {
            'FunctionName': 'string',
            'FunctionArn': 'string',
            'Runtime': 'nodejs'|'java8',
            'Role': 'string',
            'Handler': 'string',
            'CodeSize': 123,
            'Description': 'string',
            'Timeout': 123,
            'MemorySize': 123,
            'LastModified': 'string'
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    Contains a list of AWS Lambda function configurations (see FunctionConfiguration .

    • Functions (list) --

      A list of Lambda functions.

      • (dict) --

        A complex type that describes function metadata.

        • FunctionName (string) --

          The name of the function.

        • FunctionArn (string) --

          The Amazon Resource Name (ARN) assigned to the function.

        • Runtime (string) --

          The runtime environment for the Lambda function.

        • 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 Lambda calls to begin executing your function.

        • CodeSize (integer) --

          The size, in bytes, of the function .zip file you uploaded.

        • Description (string) --

          The user-provided description.

        • 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.

        • MemorySize (integer) --

          The memory size, in MB, you configured for the function. Must be a multiple of 64 MB.

        • LastModified (string) --

          The timestamp of the last time you updated the function.

    • NextToken (string) --

      A token to resume pagination.