event_source_mappings
Creates, updates, deletes or gets an event_source_mapping
resource or lists event_source_mappings
in a region
Overview
Name | event_source_mappings |
Type | Resource |
Description | The AWS::Lambda::EventSourceMapping resource creates a mapping between an event source and an LAMlong function. LAM reads items from the event source and triggers the function.For details about each event source type, see the following topics. In particular, each of the topics describes the required and optional parameters for the specific event source. + [Configuring a Dynamo DB stream as an event source](https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-dynamodb-eventsourcemapping) + [Configuring a Kinesis stream as an event source](https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html#services-kinesis-eventsourcemapping) + [Configuring an SQS queue as an event source](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#events-sqs-eventsource) + [Configuring an MQ broker as an event source](https://docs.aws.amazon.com/lambda/latest/dg/with-mq.html#services-mq-eventsourcemapping) + [Configuring MSK as an event source](https://docs.aws.amazon.com/lambda/latest/dg/with-msk.html) + [Configuring Self-Managed Apache Kafka as an event source](https://docs.aws.amazon.com/lambda/latest/dg/kafka-smaa.html) + [Configuring Amazon DocumentDB as an event source](https://docs.aws.amazon.com/lambda/latest/dg/with-documentdb.html) |
Id | aws.lambda.event_source_mappings |
Fields
Name | Datatype | Description |
---|---|---|
starting_position | string | The position in a stream from which to start reading. Required for Amazon Kinesis and Amazon DynamoDB. + *LATEST* - Read only new records. + *TRIM_HORIZON* - Process all available records. + *AT_TIMESTAMP* - Specify a time from which to start reading records. |
self_managed_event_source | object | The self-managed Apache Kafka cluster for your event source. |
parallelization_factor | integer | (Kinesis and DynamoDB Streams only) The number of batches to process concurrently from each shard. The default value is 1. |
filter_criteria | object | An object that defines the filter criteria that determine whether Lambda should process an event. For more information, see [Lambda event filtering](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html). |
function_name | string | The name or ARN 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. |
destination_config | object | (Kinesis, DynamoDB Streams, Amazon MSK, and self-managed Apache Kafka event sources only) A configuration object that specifies the destination of an event after Lambda processes it. |
amazon_managed_kafka_event_source_config | object | Specific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source. |
source_access_configurations | array | An array of the authentication protocol, VPC components, or virtual host to secure and define your event source. |
maximum_batching_window_in_seconds | integer | The maximum amount of time, in seconds, that Lambda spends gathering records before invoking the function. *Default (, , event sources)*: 0 *Default (, Kafka, , event sources)*: 500 ms *Related setting:* For SQS event sources, when you set BatchSize to a value greater than 10, you must set MaximumBatchingWindowInSeconds to at least 1. |
batch_size | integer | The maximum number of records in each batch that Lambda pulls from your stream or queue and sends to your function. Lambda passes all of the records in the batch to the function in a single call, up to the payload limit for synchronous invocation (6 MB). + *Amazon Kinesis* – Default 100. Max 10,000. + *Amazon DynamoDB Streams* – Default 100. Max 10,000. + *Amazon Simple Queue Service* – Default 10. For standard queues the max is 10,000. For FIFO queues the max is 10. + *Amazon Managed Streaming for Apache Kafka* – Default 100. Max 10,000. + *Self-managed Apache Kafka* – Default 100. Max 10,000. + *Amazon MQ (ActiveMQ and RabbitMQ)* – Default 100. Max 10,000. + *DocumentDB* – Default 100. Max 10,000. |
maximum_retry_attempts | integer | (Kinesis and DynamoDB Streams only) Discard records after the specified number of retries. The default value is -1, which sets the maximum number of retries to infinite. When MaximumRetryAttempts is infinite, Lambda retries failed records until the record expires in the event source. |
topics | array | The name of the Kafka topic. |
scaling_config | object | (Amazon SQS only) The scaling configuration for the event source. For more information, see [Configuring maximum concurrency for Amazon SQS event sources](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#events-sqs-max-concurrency). |
enabled | boolean | When true, the event source mapping is active. When false, Lambda pauses polling and invocation. Default: True |
event_source_arn | string | 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 or the ARN of the VPC connection (for [cross-account event source mappings](https://docs.aws.amazon.com/lambda/latest/dg/with-msk.html#msk-multi-vpc)). + *Amazon MQ* – The ARN of the broker. + *Amazon DocumentDB* – The ARN of the DocumentDB change stream. |
self_managed_kafka_event_source_config | object | Specific configuration settings for a self-managed Apache Kafka event source. |
document_db_event_source_config | object | Specific configuration settings for a DocumentDB event source. |
tumbling_window_in_seconds | integer | (Kinesis and DynamoDB Streams only) The duration in seconds of a processing window for DynamoDB and Kinesis Streams event sources. A value of 0 seconds indicates no tumbling window. |
bisect_batch_on_function_error | boolean | (Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry. The default value is false. |
maximum_record_age_in_seconds | integer | (Kinesis and DynamoDB Streams only) Discard records older than the specified age. The default value is -1, which sets the maximum age to infinite. When the value is set to infinite, Lambda never discards old records. The minimum valid value for maximum record age is 60s. Although values less than 60 and greater than -1 fall within the parameter's absolute range, they are not allowed |
starting_position_timestamp | number | With StartingPosition set to AT_TIMESTAMP , the time from which to start reading, in Unix time seconds. StartingPositionTimestamp cannot be in the future. |
queues | array | (Amazon MQ) The name of the Amazon MQ broker destination queue to consume. |
id | string | |
function_response_types | array | (Streams and SQS) A list of current response type enums applied to the event source mapping. Valid Values: ReportBatchItemFailures |
region | string | AWS region. |
Methods
Name | Accessible by | Required Params |
---|---|---|
create_resource | INSERT | FunctionName, region |
delete_resource | DELETE | data__Identifier, region |
update_resource | UPDATE | data__Identifier, data__PatchDocument, region |
list_resources | SELECT | region |
get_resource | SELECT | data__Identifier, region |
SELECT
examples
Gets all event_source_mappings
in a region.
SELECT
region,
starting_position,
self_managed_event_source,
parallelization_factor,
filter_criteria,
function_name,
destination_config,
amazon_managed_kafka_event_source_config,
source_access_configurations,
maximum_batching_window_in_seconds,
batch_size,
maximum_retry_attempts,
topics,
scaling_config,
enabled,
event_source_arn,
self_managed_kafka_event_source_config,
document_db_event_source_config,
tumbling_window_in_seconds,
bisect_batch_on_function_error,
maximum_record_age_in_seconds,
starting_position_timestamp,
queues,
id,
function_response_types
FROM aws.lambda.event_source_mappings
WHERE region = 'us-east-1';
Gets all properties from an individual event_source_mapping
.
SELECT
region,
starting_position,
self_managed_event_source,
parallelization_factor,
filter_criteria,
function_name,
destination_config,
amazon_managed_kafka_event_source_config,
source_access_configurations,
maximum_batching_window_in_seconds,
batch_size,
maximum_retry_attempts,
topics,
scaling_config,
enabled,
event_source_arn,
self_managed_kafka_event_source_config,
document_db_event_source_config,
tumbling_window_in_seconds,
bisect_batch_on_function_error,
maximum_record_age_in_seconds,
starting_position_timestamp,
queues,
id,
function_response_types
FROM aws.lambda.event_source_mappings
WHERE region = 'us-east-1' AND data__Identifier = '<Id>';
INSERT
example
Use the following StackQL query and manifest file to create a new event_source_mapping
resource, using stack-deploy
.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO aws.lambda.event_source_mappings (
FunctionName,
region
)
SELECT
'{{ FunctionName }}',
'{{ region }}';
/*+ create */
INSERT INTO aws.lambda.event_source_mappings (
StartingPosition,
SelfManagedEventSource,
ParallelizationFactor,
FilterCriteria,
FunctionName,
DestinationConfig,
AmazonManagedKafkaEventSourceConfig,
SourceAccessConfigurations,
MaximumBatchingWindowInSeconds,
BatchSize,
MaximumRetryAttempts,
Topics,
ScalingConfig,
Enabled,
EventSourceArn,
SelfManagedKafkaEventSourceConfig,
DocumentDBEventSourceConfig,
TumblingWindowInSeconds,
BisectBatchOnFunctionError,
MaximumRecordAgeInSeconds,
StartingPositionTimestamp,
Queues,
FunctionResponseTypes,
region
)
SELECT
'{{ StartingPosition }}',
'{{ SelfManagedEventSource }}',
'{{ ParallelizationFactor }}',
'{{ FilterCriteria }}',
'{{ FunctionName }}',
'{{ DestinationConfig }}',
'{{ AmazonManagedKafkaEventSourceConfig }}',
'{{ SourceAccessConfigurations }}',
'{{ MaximumBatchingWindowInSeconds }}',
'{{ BatchSize }}',
'{{ MaximumRetryAttempts }}',
'{{ Topics }}',
'{{ ScalingConfig }}',
'{{ Enabled }}',
'{{ EventSourceArn }}',
'{{ SelfManagedKafkaEventSourceConfig }}',
'{{ DocumentDBEventSourceConfig }}',
'{{ TumblingWindowInSeconds }}',
'{{ BisectBatchOnFunctionError }}',
'{{ MaximumRecordAgeInSeconds }}',
'{{ StartingPositionTimestamp }}',
'{{ Queues }}',
'{{ FunctionResponseTypes }}',
'{{ region }}';
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: event_source_mapping
props:
- name: StartingPosition
value: '{{ StartingPosition }}'
- name: SelfManagedEventSource
value:
Endpoints:
KafkaBootstrapServers:
- '{{ KafkaBootstrapServers[0] }}'
- name: ParallelizationFactor
value: '{{ ParallelizationFactor }}'
- name: FilterCriteria
value:
Filters:
- Pattern: '{{ Pattern }}'
- name: FunctionName
value: '{{ FunctionName }}'
- name: DestinationConfig
value:
OnFailure:
Destination: '{{ Destination }}'
- name: AmazonManagedKafkaEventSourceConfig
value:
ConsumerGroupId: '{{ ConsumerGroupId }}'
- name: SourceAccessConfigurations
value:
- Type: '{{ Type }}'
URI: '{{ URI }}'
- name: MaximumBatchingWindowInSeconds
value: '{{ MaximumBatchingWindowInSeconds }}'
- name: BatchSize
value: '{{ BatchSize }}'
- name: MaximumRetryAttempts
value: '{{ MaximumRetryAttempts }}'
- name: Topics
value:
- '{{ Topics[0] }}'
- name: ScalingConfig
value:
MaximumConcurrency: '{{ MaximumConcurrency }}'
- name: Enabled
value: '{{ Enabled }}'
- name: EventSourceArn
value: '{{ EventSourceArn }}'
- name: SelfManagedKafkaEventSourceConfig
value:
ConsumerGroupId: null
- name: DocumentDBEventSourceConfig
value:
FullDocument: '{{ FullDocument }}'
CollectionName: '{{ CollectionName }}'
DatabaseName: '{{ DatabaseName }}'
- name: TumblingWindowInSeconds
value: '{{ TumblingWindowInSeconds }}'
- name: BisectBatchOnFunctionError
value: '{{ BisectBatchOnFunctionError }}'
- name: MaximumRecordAgeInSeconds
value: '{{ MaximumRecordAgeInSeconds }}'
- name: StartingPositionTimestamp
value: null
- name: Queues
value:
- '{{ Queues[0] }}'
- name: FunctionResponseTypes
value:
- '{{ FunctionResponseTypes[0] }}'
DELETE
example
/*+ delete */
DELETE FROM aws.lambda.event_source_mappings
WHERE data__Identifier = '<Id>'
AND region = 'us-east-1';
Permissions
To operate on the event_source_mappings
resource, the following permissions are required:
Read
lambda:GetEventSourceMapping
Create
lambda:CreateEventSourceMapping,
lambda:GetEventSourceMapping
Update
lambda:UpdateEventSourceMapping,
lambda:GetEventSourceMapping
List
lambda:ListEventSourceMappings
Delete
lambda:DeleteEventSourceMapping,
lambda:GetEventSourceMapping