AWS Lambda

2015/05/07 - AWS Lambda - 17 new api methods

GetFunctionConfiguration (new) Link ¶

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

client.get_function_configuration(
    FunctionName='string'
)
type FunctionName:

string

param FunctionName:

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

rtype:

dict

returns:

Response Syntax

{
    'FunctionName': 'string',
    'FunctionArn': 'string',
    'Runtime': 'nodejs'|'jvm'|'python',
    '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.

AddPermission (new) Link ¶

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

client.add_permission(
    FunctionName='string',
    StatementId='string',
    Action='string',
    Principal='string',
    SourceArn='string',
    SourceAccount='string'
)
type FunctionName:

string

param FunctionName:

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

type StatementId:

string

param StatementId:

[REQUIRED]

A unique statement identifier.

type Action:

string

param Action:

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

type Principal:

string

param Principal:

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

type SourceArn:

string

param SourceArn:

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.

type SourceAccount:

string

param SourceAccount:

The AWS account ID (without a hyphen) of the source owner. 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.

rtype:

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.

RemovePermission (new) Link ¶

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

client.remove_permission(
    FunctionName='string',
    StatementId='string'
)
type FunctionName:

string

param FunctionName:

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

type StatementId:

string

param StatementId:

[REQUIRED]

Statement ID of the permission to remove.

returns:

None

UpdateFunctionConfiguration (new) Link ¶

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

client.update_function_configuration(
    FunctionName='string',
    Role='string',
    Handler='string',
    Description='string',
    Timeout=123,
    MemorySize=123
)
type FunctionName:

string

param FunctionName:

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

type Role:

string

param Role:

The Amazon Resource Name (ARN) of the IAM role that Lambda will assume when it executes your function.

type Handler:

string

param Handler:

The function that Lambda calls to begin executing your function. For Node.js, it is the module-name.export value in your function.

type Description:

string

param Description:

A short user-defined function description. AWS Lambda does not use this value. Assign a meaningful description as you see fit.

type Timeout:

integer

param Timeout:

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.

type MemorySize:

integer

param MemorySize:

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.

rtype:

dict

returns:

Response Syntax

{
    'FunctionName': 'string',
    'FunctionArn': 'string',
    'Runtime': 'nodejs'|'jvm'|'python',
    '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.

InvokeAsync (new) Link ¶

Request Syntax

client.invoke_async(
    FunctionName='string',
    InvokeArgs=b'bytes'|file
)
type FunctionName:

string

param FunctionName:

[REQUIRED]

type InvokeArgs:

bytes or seekable file-like object

param InvokeArgs:

[REQUIRED]

rtype:

dict

returns:

Response Syntax

{
    'Status': 123
}

Response Structure

  • (dict) --

    • Status (integer) --

GetEventSourceMapping (new) Link ¶

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

This operation requires permission for the lambda:GetEventSourceMapping action.

Request Syntax

client.get_event_source_mapping(
    UUID='string'
)
type UUID:

string

param UUID:

[REQUIRED]

The AWS Lambda assigned ID of the event source mapping.

rtype:

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.

DeleteEventSourceMapping (new) Link ¶

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

client.delete_event_source_mapping(
    UUID='string'
)
type UUID:

string

param UUID:

[REQUIRED]

The event source mapping ID.

rtype:

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.

UpdateEventSourceMapping (new) Link ¶

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

client.update_event_source_mapping(
    UUID='string',
    FunctionName='string',
    Enabled=True|False,
    BatchSize=123
)
type UUID:

string

param UUID:

[REQUIRED]

The event source mapping identifier.

type FunctionName:

string

param FunctionName:

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.

type Enabled:

boolean

param Enabled:

Specifies whether AWS Lambda should actively poll the stream or not. If disabled, AWS Lambda will not poll the stream.

type BatchSize:

integer

param BatchSize:

The maximum number of stream records that can be sent to your Lambda function for a single invocation.

rtype:

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.

UpdateFunctionCode (new) Link ¶

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 permision for the lambda:UpdateFunctionCode action.

Request Syntax

client.update_function_code(
    FunctionName='string',
    ZipFile=b'bytes'
)
type FunctionName:

string

param FunctionName:

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

type ZipFile:

bytes

param ZipFile:

[REQUIRED]

Based64-encoded .zip file containing your packaged source code.

rtype:

dict

returns:

Response Syntax

{
    'FunctionName': 'string',
    'FunctionArn': 'string',
    'Runtime': 'nodejs'|'jvm'|'python',
    '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.

DeleteFunction (new) Link ¶

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

client.delete_function(
    FunctionName='string'
)
type FunctionName:

string

param FunctionName:

[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

ListEventSourceMappings (new) Link ¶

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

client.list_event_source_mappings(
    EventSourceArn='string',
    FunctionName='string',
    Marker='string',
    MaxItems=123
)
type EventSourceArn:

string

param EventSourceArn:

The Amazon Resource Name (ARN) of the Amazon Kinesis stream.

type FunctionName:

string

param FunctionName:

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.

type Marker:

string

param Marker:

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.

type MaxItems:

integer

param MaxItems:

Optional integer. Specifies the maximum number of event sources to return in response. This value must be greater than 0.

rtype:

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

Invoke (new) Link ¶

Invokes a specified Lambda function.

This operation requires permission for the lambda:Invoke action.

Request Syntax

client.invoke(
    FunctionName='string',
    InvocationType='Event'|'RequestResponse'|'DryRun',
    LogType='None'|'Tail',
    ClientContext='string',
    Payload=b'bytes'|file
)
type FunctionName:

string

param FunctionName:

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

type InvocationType:

string

param InvocationType:

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.

type LogType:

string

param LogType:

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.

type ClientContext:

string

param ClientContext:

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.

type Payload:

bytes or seekable file-like object

param Payload:

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

rtype:

dict

returns:

Response Syntax

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

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 or seekable file-like object) --

      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.

GetFunction (new) Link ¶

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

client.get_function(
    FunctionName='string'
)
type FunctionName:

string

param FunctionName:

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

rtype:

dict

returns:

Response Syntax

{
    'Configuration': {
        'FunctionName': 'string',
        'FunctionArn': 'string',
        'Runtime': 'nodejs'|'jvm'|'python',
        '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.

GetPolicy (new) Link ¶

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

client.get_policy(
    FunctionName='string'
)
type FunctionName:

string

param FunctionName:

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

rtype:

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.

ListFunctions (new) Link ¶

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

client.list_functions(
    Marker='string',
    MaxItems=123
)
type Marker:

string

param Marker:

Optional string. An opaque pagination token returned from a previous ListFunctions operation. If present, indicates where to continue the listing.

type MaxItems:

integer

param MaxItems:

Optional integer. Specifies the maximum number of AWS Lambda functions to return in response. This parameter value must be greater than 0.

rtype:

dict

returns:

Response Syntax

{
    'NextMarker': 'string',
    'Functions': [
        {
            'FunctionName': 'string',
            'FunctionArn': 'string',
            'Runtime': 'nodejs'|'jvm'|'python',
            '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.

CreateEventSourceMapping (new) Link ¶

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

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

string

param EventSourceArn:

[REQUIRED]

The Amazon Resource Name (ARN) of the Amazon Kinesis 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.

type FunctionName:

string

param FunctionName:

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

type Enabled:

boolean

param Enabled:

Indicates whether AWS Lambda should begin polling the event source.

type BatchSize:

integer

param BatchSize:

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.

type StartingPosition:

string

param StartingPosition:

[REQUIRED]

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

rtype:

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.

CreateFunction (new) Link ¶

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

client.create_function(
    FunctionName='string',
    Runtime='nodejs'|'jvm'|'python',
    Role='string',
    Handler='string',
    Description='string',
    Timeout=123,
    MemorySize=123,
    Code={
        'ZipFile': b'bytes'
    }
)
type FunctionName:

string

param FunctionName:

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

type Runtime:

string

param Runtime:

[REQUIRED]

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

type Role:

string

param Role:

[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

type Handler:

string

param Handler:

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

type Description:

string

param Description:

A short, user-defined function description. Lambda does not use this value. Assign a meaningful description as you see fit.

type Timeout:

integer

param Timeout:

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.

type MemorySize:

integer

param MemorySize:

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.

type Code:

dict

param Code:

[REQUIRED]

A structure that includes ZipFile.

  • ZipFile (bytes) --

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

rtype:

dict

returns:

Response Syntax

{
    'FunctionName': 'string',
    'FunctionArn': 'string',
    'Runtime': 'nodejs'|'jvm'|'python',
    '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.