AWS Lambda

2020/08/11 - AWS Lambda - 5 updated api methods

Changes  Update lambda client to latest version

CreateEventSourceMapping (updated) Link ¶
Changes (both)
{'Topics': ['string']}

Creates a mapping between an event source and an AWS Lambda function. Lambda reads items from the event source and triggers the function.

For details about each event source type, see the following topics.

The following error handling options are only available for stream sources (DynamoDB and Kinesis):

  • BisectBatchOnFunctionError - If the function returns an error, split the batch in two and retry.

  • DestinationConfig - Send discarded records to an Amazon SQS queue or Amazon SNS topic.

  • MaximumRecordAgeInSeconds - Discard records older than the specified age. Default -1 (infinite). Minimum 60. Maximum 604800.

  • MaximumRetryAttempts - Discard records after the specified number of retries. Default -1 (infinite). Minimum 0. Maximum 10000. When infinite, failed records will be retried until the record expires.

  • ParallelizationFactor - Process multiple batches from each shard concurrently.

See also: AWS API Documentation

Request Syntax

client.create_event_source_mapping(
    EventSourceArn='string',
    FunctionName='string',
    Enabled=True|False,
    BatchSize=123,
    MaximumBatchingWindowInSeconds=123,
    ParallelizationFactor=123,
    StartingPosition='TRIM_HORIZON'|'LATEST'|'AT_TIMESTAMP',
    StartingPositionTimestamp=datetime(2015, 1, 1),
    DestinationConfig={
        'OnSuccess': {
            'Destination': 'string'
        },
        'OnFailure': {
            'Destination': 'string'
        }
    },
    MaximumRecordAgeInSeconds=123,
    BisectBatchOnFunctionError=True|False,
    MaximumRetryAttempts=123,
    Topics=[
        'string',
    ]
)
type EventSourceArn:

string

param EventSourceArn:

[REQUIRED]

The Amazon Resource Name (ARN) of the event source.

  • Amazon Kinesis - The ARN of the data stream or a stream consumer.

  • Amazon DynamoDB Streams - The ARN of the stream.

  • Amazon Simple Queue Service - The ARN of the queue.

  • Amazon Managed Streaming for Apache Kafka - The ARN of the cluster.

type FunctionName:

string

param FunctionName:

[REQUIRED]

The name of the Lambda function.

Name formats

  • Function name - MyFunction.

  • Function ARN - arn:aws:lambda:us-west-2:123456789012:function:MyFunction.

  • Version or Alias ARN - arn:aws:lambda:us-west-2:123456789012:function:MyFunction:PROD.

  • Partial ARN - 123456789012:function:MyFunction.

The length constraint applies only to the full ARN. If you specify only the function name, it's limited to 64 characters in length.

type Enabled:

boolean

param Enabled:

If true, the event source mapping is active. Set to false to pause polling and invocation.

type BatchSize:

integer

param BatchSize:

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

  • Amazon Kinesis - Default 100. Max 10,000.

  • Amazon DynamoDB Streams - Default 100. Max 1,000.

  • Amazon Simple Queue Service - Default 10. Max 10.

  • Amazon Managed Streaming for Apache Kafka - Default 100. Max 10,000.

type MaximumBatchingWindowInSeconds:

integer

param MaximumBatchingWindowInSeconds:

(Streams) The maximum amount of time to gather records before invoking the function, in seconds.

type ParallelizationFactor:

integer

param ParallelizationFactor:

(Streams) The number of batches to process from each shard concurrently.

type StartingPosition:

string

param StartingPosition:

The position in a stream from which to start reading. Required for Amazon Kinesis, Amazon DynamoDB, and Amazon MSK Streams sources. AT_TIMESTAMP is only supported for Amazon Kinesis streams.

type StartingPositionTimestamp:

datetime

param StartingPositionTimestamp:

With StartingPosition set to AT_TIMESTAMP, the time from which to start reading.

type DestinationConfig:

dict

param DestinationConfig:

(Streams) An Amazon SQS queue or Amazon SNS topic destination for discarded records.

  • OnSuccess (dict) --

    The destination configuration for successful invocations.

    • Destination (string) --

      The Amazon Resource Name (ARN) of the destination resource.

  • OnFailure (dict) --

    The destination configuration for failed invocations.

    • Destination (string) --

      The Amazon Resource Name (ARN) of the destination resource.

type MaximumRecordAgeInSeconds:

integer

param MaximumRecordAgeInSeconds:

(Streams) Discard records older than the specified age. The default value is infinite (-1).

type BisectBatchOnFunctionError:

boolean

param BisectBatchOnFunctionError:

(Streams) If the function returns an error, split the batch in two and retry.

type MaximumRetryAttempts:

integer

param MaximumRetryAttempts:

(Streams) Discard records after the specified number of retries. The default value is infinite (-1). When set to infinite (-1), failed records will be retried until the record expires.

type Topics:

list

param Topics:

(MSK) The name of the Kafka topic.

  • (string) --

rtype:

dict

returns:

Response Syntax

{
    'UUID': 'string',
    'BatchSize': 123,
    'MaximumBatchingWindowInSeconds': 123,
    'ParallelizationFactor': 123,
    'EventSourceArn': 'string',
    'FunctionArn': 'string',
    'LastModified': datetime(2015, 1, 1),
    'LastProcessingResult': 'string',
    'State': 'string',
    'StateTransitionReason': 'string',
    'DestinationConfig': {
        'OnSuccess': {
            'Destination': 'string'
        },
        'OnFailure': {
            'Destination': 'string'
        }
    },
    'Topics': [
        'string',
    ],
    'MaximumRecordAgeInSeconds': 123,
    'BisectBatchOnFunctionError': True|False,
    'MaximumRetryAttempts': 123
}

Response Structure

  • (dict) --

    A mapping between an AWS resource and an AWS Lambda function. See CreateEventSourceMapping for details.

    • UUID (string) --

      The identifier of the event source mapping.

    • BatchSize (integer) --

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

    • MaximumBatchingWindowInSeconds (integer) --

      (Streams) The maximum amount of time to gather records before invoking the function, in seconds.

    • ParallelizationFactor (integer) --

      (Streams) The number of batches to process from each shard concurrently.

    • EventSourceArn (string) --

      The Amazon Resource Name (ARN) of the event source.

    • FunctionArn (string) --

      The ARN of the Lambda function.

    • LastModified (datetime) --

      The date that the event source mapping was last updated, or its state changed.

    • 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 one of the following: Creating, Enabling, Enabled, Disabling, Disabled, Updating, or Deleting.

    • StateTransitionReason (string) --

      Indicates whether the last change to the event source mapping was made by a user, or by the Lambda service.

    • DestinationConfig (dict) --

      (Streams) An Amazon SQS queue or Amazon SNS topic destination for discarded records.

      • OnSuccess (dict) --

        The destination configuration for successful invocations.

        • Destination (string) --

          The Amazon Resource Name (ARN) of the destination resource.

      • OnFailure (dict) --

        The destination configuration for failed invocations.

        • Destination (string) --

          The Amazon Resource Name (ARN) of the destination resource.

    • Topics (list) --

      (MSK) The name of the Kafka topic.

      • (string) --

    • MaximumRecordAgeInSeconds (integer) --

      (Streams) The maximum age of a record that Lambda sends to a function for processing.

    • BisectBatchOnFunctionError (boolean) --

      (Streams) If the function returns an error, split the batch in two and retry.

    • MaximumRetryAttempts (integer) --

      (Streams) The maximum number of times to retry when the function returns an error.

DeleteEventSourceMapping (updated) Link ¶
Changes (response)
{'Topics': ['string']}

Deletes an event source mapping. You can get the identifier of a mapping from the output of ListEventSourceMappings.

When you delete an event source mapping, it enters a Deleting state and might not be completely deleted for several seconds.

See also: AWS API Documentation

Request Syntax

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

string

param UUID:

[REQUIRED]

The identifier of the event source mapping.

rtype:

dict

returns:

Response Syntax

{
    'UUID': 'string',
    'BatchSize': 123,
    'MaximumBatchingWindowInSeconds': 123,
    'ParallelizationFactor': 123,
    'EventSourceArn': 'string',
    'FunctionArn': 'string',
    'LastModified': datetime(2015, 1, 1),
    'LastProcessingResult': 'string',
    'State': 'string',
    'StateTransitionReason': 'string',
    'DestinationConfig': {
        'OnSuccess': {
            'Destination': 'string'
        },
        'OnFailure': {
            'Destination': 'string'
        }
    },
    'Topics': [
        'string',
    ],
    'MaximumRecordAgeInSeconds': 123,
    'BisectBatchOnFunctionError': True|False,
    'MaximumRetryAttempts': 123
}

Response Structure

  • (dict) --

    A mapping between an AWS resource and an AWS Lambda function. See CreateEventSourceMapping for details.

    • UUID (string) --

      The identifier of the event source mapping.

    • BatchSize (integer) --

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

    • MaximumBatchingWindowInSeconds (integer) --

      (Streams) The maximum amount of time to gather records before invoking the function, in seconds.

    • ParallelizationFactor (integer) --

      (Streams) The number of batches to process from each shard concurrently.

    • EventSourceArn (string) --

      The Amazon Resource Name (ARN) of the event source.

    • FunctionArn (string) --

      The ARN of the Lambda function.

    • LastModified (datetime) --

      The date that the event source mapping was last updated, or its state changed.

    • 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 one of the following: Creating, Enabling, Enabled, Disabling, Disabled, Updating, or Deleting.

    • StateTransitionReason (string) --

      Indicates whether the last change to the event source mapping was made by a user, or by the Lambda service.

    • DestinationConfig (dict) --

      (Streams) An Amazon SQS queue or Amazon SNS topic destination for discarded records.

      • OnSuccess (dict) --

        The destination configuration for successful invocations.

        • Destination (string) --

          The Amazon Resource Name (ARN) of the destination resource.

      • OnFailure (dict) --

        The destination configuration for failed invocations.

        • Destination (string) --

          The Amazon Resource Name (ARN) of the destination resource.

    • Topics (list) --

      (MSK) The name of the Kafka topic.

      • (string) --

    • MaximumRecordAgeInSeconds (integer) --

      (Streams) The maximum age of a record that Lambda sends to a function for processing.

    • BisectBatchOnFunctionError (boolean) --

      (Streams) If the function returns an error, split the batch in two and retry.

    • MaximumRetryAttempts (integer) --

      (Streams) The maximum number of times to retry when the function returns an error.

GetEventSourceMapping (updated) Link ¶
Changes (response)
{'Topics': ['string']}

Returns details about an event source mapping. You can get the identifier of a mapping from the output of ListEventSourceMappings.

See also: AWS API Documentation

Request Syntax

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

string

param UUID:

[REQUIRED]

The identifier of the event source mapping.

rtype:

dict

returns:

Response Syntax

{
    'UUID': 'string',
    'BatchSize': 123,
    'MaximumBatchingWindowInSeconds': 123,
    'ParallelizationFactor': 123,
    'EventSourceArn': 'string',
    'FunctionArn': 'string',
    'LastModified': datetime(2015, 1, 1),
    'LastProcessingResult': 'string',
    'State': 'string',
    'StateTransitionReason': 'string',
    'DestinationConfig': {
        'OnSuccess': {
            'Destination': 'string'
        },
        'OnFailure': {
            'Destination': 'string'
        }
    },
    'Topics': [
        'string',
    ],
    'MaximumRecordAgeInSeconds': 123,
    'BisectBatchOnFunctionError': True|False,
    'MaximumRetryAttempts': 123
}

Response Structure

  • (dict) --

    A mapping between an AWS resource and an AWS Lambda function. See CreateEventSourceMapping for details.

    • UUID (string) --

      The identifier of the event source mapping.

    • BatchSize (integer) --

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

    • MaximumBatchingWindowInSeconds (integer) --

      (Streams) The maximum amount of time to gather records before invoking the function, in seconds.

    • ParallelizationFactor (integer) --

      (Streams) The number of batches to process from each shard concurrently.

    • EventSourceArn (string) --

      The Amazon Resource Name (ARN) of the event source.

    • FunctionArn (string) --

      The ARN of the Lambda function.

    • LastModified (datetime) --

      The date that the event source mapping was last updated, or its state changed.

    • 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 one of the following: Creating, Enabling, Enabled, Disabling, Disabled, Updating, or Deleting.

    • StateTransitionReason (string) --

      Indicates whether the last change to the event source mapping was made by a user, or by the Lambda service.

    • DestinationConfig (dict) --

      (Streams) An Amazon SQS queue or Amazon SNS topic destination for discarded records.

      • OnSuccess (dict) --

        The destination configuration for successful invocations.

        • Destination (string) --

          The Amazon Resource Name (ARN) of the destination resource.

      • OnFailure (dict) --

        The destination configuration for failed invocations.

        • Destination (string) --

          The Amazon Resource Name (ARN) of the destination resource.

    • Topics (list) --

      (MSK) The name of the Kafka topic.

      • (string) --

    • MaximumRecordAgeInSeconds (integer) --

      (Streams) The maximum age of a record that Lambda sends to a function for processing.

    • BisectBatchOnFunctionError (boolean) --

      (Streams) If the function returns an error, split the batch in two and retry.

    • MaximumRetryAttempts (integer) --

      (Streams) The maximum number of times to retry when the function returns an error.

ListEventSourceMappings (updated) Link ¶
Changes (response)
{'EventSourceMappings': {'Topics': ['string']}}

Lists event source mappings. Specify an EventSourceArn to only show event source mappings for a single event source.

See also: AWS API Documentation

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 event source.

  • Amazon Kinesis - The ARN of the data stream or a stream consumer.

  • Amazon DynamoDB Streams - The ARN of the stream.

  • Amazon Simple Queue Service - The ARN of the queue.

  • Amazon Managed Streaming for Apache Kafka - The ARN of the cluster.

type FunctionName:

string

param FunctionName:

The name of the Lambda function.

Name formats

  • Function name - MyFunction.

  • Function ARN - arn:aws:lambda:us-west-2:123456789012:function:MyFunction.

  • Version or Alias ARN - arn:aws:lambda:us-west-2:123456789012:function:MyFunction:PROD.

  • Partial ARN - 123456789012:function:MyFunction.

The length constraint applies only to the full ARN. If you specify only the function name, it's limited to 64 characters in length.

type Marker:

string

param Marker:

A pagination token returned by a previous call.

type MaxItems:

integer

param MaxItems:

The maximum number of event source mappings to return.

rtype:

dict

returns:

Response Syntax

{
    'NextMarker': 'string',
    'EventSourceMappings': [
        {
            'UUID': 'string',
            'BatchSize': 123,
            'MaximumBatchingWindowInSeconds': 123,
            'ParallelizationFactor': 123,
            'EventSourceArn': 'string',
            'FunctionArn': 'string',
            'LastModified': datetime(2015, 1, 1),
            'LastProcessingResult': 'string',
            'State': 'string',
            'StateTransitionReason': 'string',
            'DestinationConfig': {
                'OnSuccess': {
                    'Destination': 'string'
                },
                'OnFailure': {
                    'Destination': 'string'
                }
            },
            'Topics': [
                'string',
            ],
            'MaximumRecordAgeInSeconds': 123,
            'BisectBatchOnFunctionError': True|False,
            'MaximumRetryAttempts': 123
        },
    ]
}

Response Structure

  • (dict) --

    • NextMarker (string) --

      A pagination token that's returned when the response doesn't contain all event source mappings.

    • EventSourceMappings (list) --

      A list of event source mappings.

      • (dict) --

        A mapping between an AWS resource and an AWS Lambda function. See CreateEventSourceMapping for details.

        • UUID (string) --

          The identifier of the event source mapping.

        • BatchSize (integer) --

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

        • MaximumBatchingWindowInSeconds (integer) --

          (Streams) The maximum amount of time to gather records before invoking the function, in seconds.

        • ParallelizationFactor (integer) --

          (Streams) The number of batches to process from each shard concurrently.

        • EventSourceArn (string) --

          The Amazon Resource Name (ARN) of the event source.

        • FunctionArn (string) --

          The ARN of the Lambda function.

        • LastModified (datetime) --

          The date that the event source mapping was last updated, or its state changed.

        • 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 one of the following: Creating, Enabling, Enabled, Disabling, Disabled, Updating, or Deleting.

        • StateTransitionReason (string) --

          Indicates whether the last change to the event source mapping was made by a user, or by the Lambda service.

        • DestinationConfig (dict) --

          (Streams) An Amazon SQS queue or Amazon SNS topic destination for discarded records.

          • OnSuccess (dict) --

            The destination configuration for successful invocations.

            • Destination (string) --

              The Amazon Resource Name (ARN) of the destination resource.

          • OnFailure (dict) --

            The destination configuration for failed invocations.

            • Destination (string) --

              The Amazon Resource Name (ARN) of the destination resource.

        • Topics (list) --

          (MSK) The name of the Kafka topic.

          • (string) --

        • MaximumRecordAgeInSeconds (integer) --

          (Streams) The maximum age of a record that Lambda sends to a function for processing.

        • BisectBatchOnFunctionError (boolean) --

          (Streams) If the function returns an error, split the batch in two and retry.

        • MaximumRetryAttempts (integer) --

          (Streams) The maximum number of times to retry when the function returns an error.

UpdateEventSourceMapping (updated) Link ¶
Changes (response)
{'Topics': ['string']}

Updates an event source mapping. You can change the function that AWS Lambda invokes, or pause invocation and resume later from the same location.

The following error handling options are only available for stream sources (DynamoDB and Kinesis):

  • BisectBatchOnFunctionError - If the function returns an error, split the batch in two and retry.

  • DestinationConfig - Send discarded records to an Amazon SQS queue or Amazon SNS topic.

  • MaximumRecordAgeInSeconds - Discard records older than the specified age. Default -1 (infinite). Minimum 60. Maximum 604800.

  • MaximumRetryAttempts - Discard records after the specified number of retries. Default -1 (infinite). Minimum 0. Maximum 10000. When infinite, failed records will be retried until the record expires.

  • ParallelizationFactor - Process multiple batches from each shard concurrently.

See also: AWS API Documentation

Request Syntax

client.update_event_source_mapping(
    UUID='string',
    FunctionName='string',
    Enabled=True|False,
    BatchSize=123,
    MaximumBatchingWindowInSeconds=123,
    DestinationConfig={
        'OnSuccess': {
            'Destination': 'string'
        },
        'OnFailure': {
            'Destination': 'string'
        }
    },
    MaximumRecordAgeInSeconds=123,
    BisectBatchOnFunctionError=True|False,
    MaximumRetryAttempts=123,
    ParallelizationFactor=123
)
type UUID:

string

param UUID:

[REQUIRED]

The identifier of the event source mapping.

type FunctionName:

string

param FunctionName:

The name of the Lambda function.

Name formats

  • Function name - MyFunction.

  • Function ARN - arn:aws:lambda:us-west-2:123456789012:function:MyFunction.

  • Version or Alias ARN - arn:aws:lambda:us-west-2:123456789012:function:MyFunction:PROD.

  • Partial ARN - 123456789012:function:MyFunction.

The length constraint applies only to the full ARN. If you specify only the function name, it's limited to 64 characters in length.

type Enabled:

boolean

param Enabled:

If true, the event source mapping is active. Set to false to pause polling and invocation.

type BatchSize:

integer

param BatchSize:

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

  • Amazon Kinesis - Default 100. Max 10,000.

  • Amazon DynamoDB Streams - Default 100. Max 1,000.

  • Amazon Simple Queue Service - Default 10. Max 10.

  • Amazon Managed Streaming for Apache Kafka - Default 100. Max 10,000.

type MaximumBatchingWindowInSeconds:

integer

param MaximumBatchingWindowInSeconds:

(Streams) The maximum amount of time to gather records before invoking the function, in seconds.

type DestinationConfig:

dict

param DestinationConfig:

(Streams) An Amazon SQS queue or Amazon SNS topic destination for discarded records.

  • OnSuccess (dict) --

    The destination configuration for successful invocations.

    • Destination (string) --

      The Amazon Resource Name (ARN) of the destination resource.

  • OnFailure (dict) --

    The destination configuration for failed invocations.

    • Destination (string) --

      The Amazon Resource Name (ARN) of the destination resource.

type MaximumRecordAgeInSeconds:

integer

param MaximumRecordAgeInSeconds:

(Streams) Discard records older than the specified age. The default value is infinite (-1).

type BisectBatchOnFunctionError:

boolean

param BisectBatchOnFunctionError:

(Streams) If the function returns an error, split the batch in two and retry.

type MaximumRetryAttempts:

integer

param MaximumRetryAttempts:

(Streams) Discard records after the specified number of retries. The default value is infinite (-1). When set to infinite (-1), failed records will be retried until the record expires.

type ParallelizationFactor:

integer

param ParallelizationFactor:

(Streams) The number of batches to process from each shard concurrently.

rtype:

dict

returns:

Response Syntax

{
    'UUID': 'string',
    'BatchSize': 123,
    'MaximumBatchingWindowInSeconds': 123,
    'ParallelizationFactor': 123,
    'EventSourceArn': 'string',
    'FunctionArn': 'string',
    'LastModified': datetime(2015, 1, 1),
    'LastProcessingResult': 'string',
    'State': 'string',
    'StateTransitionReason': 'string',
    'DestinationConfig': {
        'OnSuccess': {
            'Destination': 'string'
        },
        'OnFailure': {
            'Destination': 'string'
        }
    },
    'Topics': [
        'string',
    ],
    'MaximumRecordAgeInSeconds': 123,
    'BisectBatchOnFunctionError': True|False,
    'MaximumRetryAttempts': 123
}

Response Structure

  • (dict) --

    A mapping between an AWS resource and an AWS Lambda function. See CreateEventSourceMapping for details.

    • UUID (string) --

      The identifier of the event source mapping.

    • BatchSize (integer) --

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

    • MaximumBatchingWindowInSeconds (integer) --

      (Streams) The maximum amount of time to gather records before invoking the function, in seconds.

    • ParallelizationFactor (integer) --

      (Streams) The number of batches to process from each shard concurrently.

    • EventSourceArn (string) --

      The Amazon Resource Name (ARN) of the event source.

    • FunctionArn (string) --

      The ARN of the Lambda function.

    • LastModified (datetime) --

      The date that the event source mapping was last updated, or its state changed.

    • 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 one of the following: Creating, Enabling, Enabled, Disabling, Disabled, Updating, or Deleting.

    • StateTransitionReason (string) --

      Indicates whether the last change to the event source mapping was made by a user, or by the Lambda service.

    • DestinationConfig (dict) --

      (Streams) An Amazon SQS queue or Amazon SNS topic destination for discarded records.

      • OnSuccess (dict) --

        The destination configuration for successful invocations.

        • Destination (string) --

          The Amazon Resource Name (ARN) of the destination resource.

      • OnFailure (dict) --

        The destination configuration for failed invocations.

        • Destination (string) --

          The Amazon Resource Name (ARN) of the destination resource.

    • Topics (list) --

      (MSK) The name of the Kafka topic.

      • (string) --

    • MaximumRecordAgeInSeconds (integer) --

      (Streams) The maximum age of a record that Lambda sends to a function for processing.

    • BisectBatchOnFunctionError (boolean) --

      (Streams) If the function returns an error, split the batch in two and retry.

    • MaximumRetryAttempts (integer) --

      (Streams) The maximum number of times to retry when the function returns an error.