AWS Lambda

2014/11/12 - AWS Lambda - 11 new api methods

AddEventSource (new) Link ¶

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

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

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

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

Request Syntax

client.add_event_source(
    EventSource='string',
    FunctionName='string',
    Role='string',
    BatchSize=123,
    Parameters={
        'string': 'string'
    }
)
type EventSource

string

param EventSource

[REQUIRED]

The Amazon Resource Name (ARN) of the Amazon Kinesis stream that is the event source. Any record added to this stream causes AWS Lambda to invoke your Lambda function. AWS Lambda POSTs the Amazon Kinesis event, containing records, to your Lambda function as JSON.

type FunctionName

string

param FunctionName

[REQUIRED]

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

type Role

string

param Role

[REQUIRED]

The ARN of the IAM role (invocation role) that AWS Lambda can assume to read from the stream and invoke the function.

type BatchSize

integer

param BatchSize

The largest number of records that AWS Lambda will give to your function in a single event. The default is 100 records.

type Parameters

dict

param Parameters

A map (key-value pairs) defining the configuration for AWS Lambda to use when reading the event source. Currently, AWS Lambda supports only the InitialPositionInStream key. The valid values are: "TRIM_HORIZON" and "LATEST". The default value is "TRIM_HORIZON". For more information, go to ShardIteratorType in the Amazon Kinesis Service API Reference.

  • (string) --

    • (string) --

rtype

dict

returns

Response Syntax

{
    'UUID': 'string',
    'BatchSize': 123,
    'EventSource': 'string',
    'FunctionName': 'string',
    'Parameters': {
        'string': 'string'
    },
    'Role': 'string',
    'LastModified': datetime(2015, 1, 1),
    'IsActive': True|False,
    'Status': '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 POST in the invocation request to your function.

    • EventSource (string) --

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

    • FunctionName (string) --

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

    • Parameters (dict) --

      The map (key-value pairs) defining the configuration for AWS Lambda to use when reading the event source.

      • (string) --

        • (string) --

    • Role (string) --

      The ARN of the IAM role (invocation role) that AWS Lambda can assume to read from the stream and invoke the function.

    • LastModified (datetime) --

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

    • IsActive (boolean) --

      Indicates whether the event source mapping is currently honored. Events are only processes if IsActive is true.

    • Status (string) --

      The description of the health of the event source mapping. Valid values are: "PENDING", "OK", and "PROBLEM:message ". Initially this staus is "PENDING". When AWS Lambda begins processing events, it changes the status to "OK".

GetEventSource (new) Link ¶

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

This operation requires permission for the lambda:GetEventSource action.

Request Syntax

client.get_event_source(
    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,
    'EventSource': 'string',
    'FunctionName': 'string',
    'Parameters': {
        'string': 'string'
    },
    'Role': 'string',
    'LastModified': datetime(2015, 1, 1),
    'IsActive': True|False,
    'Status': '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 POST in the invocation request to your function.

    • EventSource (string) --

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

    • FunctionName (string) --

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

    • Parameters (dict) --

      The map (key-value pairs) defining the configuration for AWS Lambda to use when reading the event source.

      • (string) --

        • (string) --

    • Role (string) --

      The ARN of the IAM role (invocation role) that AWS Lambda can assume to read from the stream and invoke the function.

    • LastModified (datetime) --

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

    • IsActive (boolean) --

      Indicates whether the event source mapping is currently honored. Events are only processes if IsActive is true.

    • Status (string) --

      The description of the health of the event source mapping. Valid values are: "PENDING", "OK", and "PROBLEM:message ". Initially this staus is "PENDING". When AWS Lambda begins processing events, it changes the status to "OK".

GetFunction (new) Link ¶

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

This operation requires permission for the lambda:GetFunction action.

Request Syntax

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

string

param FunctionName

[REQUIRED]

The Lambda function name.

rtype

dict

returns

Response Syntax

{
    'Configuration': {
        'FunctionName': 'string',
        'FunctionARN': 'string',
        'ConfigurationId': 'string',
        'Runtime': 'nodejs',
        'Role': 'string',
        'Handler': 'string',
        'Mode': 'event',
        'CodeSize': 123,
        'Description': 'string',
        'Timeout': 123,
        'MemorySize': 123,
        'LastModified': datetime(2015, 1, 1)
    },
    'Code': {
        'RepositoryType': 'string',
        'Location': 'string'
    }
}

Response Structure

  • (dict) --

    This response contains the object for AWS 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.

      • ConfigurationId (string) --

        A Lambda-assigned unique identifier for the current function code and related configuration.

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

      • Mode (string) --

        The type of the Lambda function you uploaded.

      • 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 (datetime) --

        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.

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

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.

rtype

dict

returns

Response Syntax

{
    'FunctionName': 'string',
    'FunctionARN': 'string',
    'ConfigurationId': 'string',
    'Runtime': 'nodejs',
    'Role': 'string',
    'Handler': 'string',
    'Mode': 'event',
    'CodeSize': 123,
    'Description': 'string',
    'Timeout': 123,
    'MemorySize': 123,
    'LastModified': datetime(2015, 1, 1)
}

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.

    • ConfigurationId (string) --

      A Lambda-assigned unique identifier for the current function code and related configuration.

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

    • Mode (string) --

      The type of the Lambda function you uploaded.

    • 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 (datetime) --

      The timestamp of the last time you updated the function.

RemoveEventSource (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:RemoveEventSource action.

Request Syntax

client.remove_event_source(
    UUID='string'
)
type UUID

string

param UUID

[REQUIRED]

The event source mapping ID.

returns

None

UploadFunction (new) Link ¶

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

This operation requires permission for the lambda:UploadFunction action.

Request Syntax

client.upload_function(
    FunctionName='string',
    FunctionZip=b'bytes'|file,
    Runtime='nodejs',
    Role='string',
    Handler='string',
    Mode='event',
    Description='string',
    Timeout=123,
    MemorySize=123
)
type FunctionName

string

param FunctionName

[REQUIRED]

The name you want to assign to the function you are uploading. The function names appear in the console and are returned in the ListFunctions API. Function names are used to specify functions to other AWS Lambda APIs, such as InvokeAsync.

type FunctionZip

bytes or seekable file-like object

param FunctionZip

[REQUIRED]

A .zip file containing your packaged source code. For more information about creating a .zip file, go to AWS LambdaL How it Works in the AWS Lambda Developer Guide.

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.

type Handler

string

param Handler

[REQUIRED]

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

type Mode

string

param Mode

[REQUIRED]

How the Lambda function will be invoked. Lambda supports only the "event" mode.

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 allocated to your function. Your function use-case determines your CPU and memory requirements. For example, database operation might need less memory compared to image processing function. The default value is 128 MB. The value must be a multiple of 64 MB.

rtype

dict

returns

Response Syntax

{
    'FunctionName': 'string',
    'FunctionARN': 'string',
    'ConfigurationId': 'string',
    'Runtime': 'nodejs',
    'Role': 'string',
    'Handler': 'string',
    'Mode': 'event',
    'CodeSize': 123,
    'Description': 'string',
    'Timeout': 123,
    'MemorySize': 123,
    'LastModified': datetime(2015, 1, 1)
}

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.

    • ConfigurationId (string) --

      A Lambda-assigned unique identifier for the current function code and related configuration.

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

    • Mode (string) --

      The type of the Lambda function you uploaded.

    • 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 (datetime) --

      The timestamp of the last time you updated the function.

InvokeAsync (new) Link ¶

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

This operation requires permission for the lambda:InvokeAsync action.

Request Syntax

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

string

param FunctionName

[REQUIRED]

The Lambda function name.

type InvokeArgs

bytes or seekable file-like object

param InvokeArgs

[REQUIRED]

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

rtype

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.

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',
            'ConfigurationId': 'string',
            'Runtime': 'nodejs',
            'Role': 'string',
            'Handler': 'string',
            'Mode': 'event',
            'CodeSize': 123,
            'Description': 'string',
            'Timeout': 123,
            'MemorySize': 123,
            'LastModified': datetime(2015, 1, 1)
        },
    ]
}

Response Structure

  • (dict) --

    Contains a list of AWS Lambda function configurations (see API_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.

        • ConfigurationId (string) --

          A Lambda-assigned unique identifier for the current function code and related configuration.

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

        • Mode (string) --

          The type of the Lambda function you uploaded.

        • 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 (datetime) --

          The timestamp of the last time you updated the function.

DeleteFunction (new) Link ¶

Deletes the specified Lambda function code and configuration.

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.

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.

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. 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 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',
    'ConfigurationId': 'string',
    'Runtime': 'nodejs',
    'Role': 'string',
    'Handler': 'string',
    'Mode': 'event',
    'CodeSize': 123,
    'Description': 'string',
    'Timeout': 123,
    'MemorySize': 123,
    'LastModified': datetime(2015, 1, 1)
}

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.

    • ConfigurationId (string) --

      A Lambda-assigned unique identifier for the current function code and related configuration.

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

    • Mode (string) --

      The type of the Lambda function you uploaded.

    • 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 (datetime) --

      The timestamp of the last time you updated the function.

ListEventSources (new) Link ¶

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

This operation requires permission for the lambda:ListEventSources action.

Request Syntax

client.list_event_sources(
    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 AWS Lambda function.

type Marker

string

param Marker

Optional string. An opaque pagination token returned from a previous ListEventSources operation. If present, specifies to continue the list from where the returning call left off.

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',
    'EventSources': [
        {
            'UUID': 'string',
            'BatchSize': 123,
            'EventSource': 'string',
            'FunctionName': 'string',
            'Parameters': {
                'string': 'string'
            },
            'Role': 'string',
            'LastModified': datetime(2015, 1, 1),
            'IsActive': True|False,
            'Status': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    Contains a list of event sources (see API_EventSourceConfiguration )

    • NextMarker (string) --

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

    • EventSources (list) --

      An arrary of EventSourceConfiguration 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 POST in the invocation request to your function.

        • EventSource (string) --

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

        • FunctionName (string) --

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

        • Parameters (dict) --

          The map (key-value pairs) defining the configuration for AWS Lambda to use when reading the event source.

          • (string) --

            • (string) --

        • Role (string) --

          The ARN of the IAM role (invocation role) that AWS Lambda can assume to read from the stream and invoke the function.

        • LastModified (datetime) --

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

        • IsActive (boolean) --

          Indicates whether the event source mapping is currently honored. Events are only processes if IsActive is true.

        • Status (string) --

          The description of the health of the event source mapping. Valid values are: "PENDING", "OK", and "PROBLEM:message ". Initially this staus is "PENDING". When AWS Lambda begins processing events, it changes the status to "OK".