Skip to main content

event_source_mappings

Creates, updates, deletes or gets an event_source_mapping resource or lists event_source_mappings in a region

Overview

Nameevent_source_mappings
TypeResource
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
+ Configuring a Kinesis stream as an event source
+ Configuring an SQS queue as an event source
+ Configuring an MQ broker as an event source
+ Configuring MSK as an event source
+ Configuring Self-Managed Apache Kafka as an event source
+ Configuring Amazon DocumentDB as an event source
Idawscc.lambda.event_source_mappings

Fields

NameDatatypeDescription
idstring
batch_sizeinteger
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.
bisect_batch_on_function_errorboolean
(Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry. The default value is false.When using BisectBatchOnFunctionError, check the BatchSize parameter in the OnFailure destination message's metadata. The BatchSize could be greater than 1 since LAM consolidates failed messages metadata when writing to the OnFailure destination.
destination_configobject(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.
enabledboolean
When true, the event source mapping is active. When false, Lambda pauses polling and invocation.Default: True
event_source_arnstring
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).
+ Amazon MQ – The ARN of the broker.
+ Amazon DocumentDB – The ARN of the DocumentDB change stream.
event_source_mapping_arnstring
filter_criteriaobjectAn object that defines the filter criteria that determine whether Lambda should process an event. For more information, see Lambda event filtering.
kms_key_arnstringThe ARN of the KMSlong (KMS) customer managed key that Lambda uses to encrypt your function's filter criteria.
function_namestring
The name or ARN of the Lambda function.Name formats
+ Function nameMyFunction.
+ Function ARNarn:aws:lambda:us-west-2:123456789012:function:MyFunction.
+ Version or Alias ARNarn:aws:lambda:us-west-2:123456789012:function:MyFunction:PROD.
+ Partial ARN123456789012: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.
maximum_batching_window_in_secondsinteger
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.
maximum_record_age_in_secondsinteger
(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
maximum_retry_attemptsinteger(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.
parallelization_factorinteger(Kinesis and DynamoDB Streams only) The number of batches to process concurrently from each shard. The default value is 1.
starting_positionstring
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.
starting_position_timestampnumberWith StartingPosition set to AT_TIMESTAMP, the time from which to start reading, in Unix time seconds. StartingPositionTimestamp cannot be in the future.
tagsarray
A list of tags to add to the event source mapping.You must have the lambda:TagResource, lambda:UntagResource, and lambda:ListTags permissions for your principal to manage the CFN stack. If you don't have these permissions, there might be unexpected behavior with stack-level tags propagating to the resource during resource creation and update.
topicsarrayThe name of the Kafka topic.
queuesarray(Amazon MQ) The name of the Amazon MQ broker destination queue to consume.
source_access_configurationsarrayAn array of the authentication protocol, VPC components, or virtual host to secure and define your event source.
tumbling_window_in_secondsinteger(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.
function_response_typesarray
(Kinesis, DynamoDB Streams, and SQS) A list of current response type enums applied to the event source mapping.Valid Values: ReportBatchItemFailures
self_managed_event_sourceobjectThe self-managed Apache Kafka cluster for your event source.
amazon_managed_kafka_event_source_configobjectSpecific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source.
self_managed_kafka_event_source_configobjectSpecific configuration settings for a self-managed Apache Kafka event source.
scaling_configobject(Amazon SQS only) The scaling configuration for the event source. For more information, see Configuring maximum concurrency for Amazon SQS event sources.
document_db_event_source_configobjectSpecific configuration settings for a DocumentDB event source.
provisioned_poller_configobject(Amazon MSK and self-managed Apache Kafka only) The provisioned mode configuration for the event source. For more information, see provisioned mode.
metrics_configobjectThe metrics configuration for your event source. For more information, see Event source mapping metrics.
regionstringAWS region.

For more information, see AWS::Lambda::EventSourceMapping.

Methods

NameResourceAccessible byRequired Params
create_resourceevent_source_mappingsINSERTFunctionName, region
delete_resourceevent_source_mappingsDELETEIdentifier, region
update_resourceevent_source_mappingsUPDATEIdentifier, PatchDocument, region
list_resourcesevent_source_mappings_list_onlySELECTregion
get_resourceevent_source_mappingsSELECTIdentifier, region

SELECT examples

Gets all properties from an individual event_source_mapping.

SELECT
region,
id,
batch_size,
bisect_batch_on_function_error,
destination_config,
enabled,
event_source_arn,
event_source_mapping_arn,
filter_criteria,
kms_key_arn,
function_name,
maximum_batching_window_in_seconds,
maximum_record_age_in_seconds,
maximum_retry_attempts,
parallelization_factor,
starting_position,
starting_position_timestamp,
tags,
topics,
queues,
source_access_configurations,
tumbling_window_in_seconds,
function_response_types,
self_managed_event_source,
amazon_managed_kafka_event_source_config,
self_managed_kafka_event_source_config,
scaling_config,
document_db_event_source_config,
provisioned_poller_config,
metrics_config
FROM awscc.lambda.event_source_mappings
WHERE
region = '{{ region }}' AND
Identifier = '{{ id }}';

INSERT example

Use the following StackQL query and manifest file to create a new event_source_mapping resource, using stack-deploy.

/*+ create */
INSERT INTO awscc.lambda.event_source_mappings (
FunctionName,
region
)
SELECT
'{{ function_name }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

UPDATE example

Use the following StackQL query and manifest file to update a event_source_mapping resource, using stack-deploy.

/*+ update */
UPDATE awscc.lambda.event_source_mappings
SET PatchDocument = string('{{ {
"BatchSize": batch_size,
"BisectBatchOnFunctionError": bisect_batch_on_function_error,
"DestinationConfig": destination_config,
"Enabled": enabled,
"FilterCriteria": filter_criteria,
"KmsKeyArn": kms_key_arn,
"FunctionName": function_name,
"MaximumBatchingWindowInSeconds": maximum_batching_window_in_seconds,
"MaximumRecordAgeInSeconds": maximum_record_age_in_seconds,
"MaximumRetryAttempts": maximum_retry_attempts,
"ParallelizationFactor": parallelization_factor,
"Tags": tags,
"Topics": topics,
"Queues": queues,
"SourceAccessConfigurations": source_access_configurations,
"TumblingWindowInSeconds": tumbling_window_in_seconds,
"FunctionResponseTypes": function_response_types,
"AmazonManagedKafkaEventSourceConfig": amazon_managed_kafka_event_source_config,
"SelfManagedKafkaEventSourceConfig": self_managed_kafka_event_source_config,
"ScalingConfig": scaling_config,
"DocumentDBEventSourceConfig": document_db_event_source_config,
"ProvisionedPollerConfig": provisioned_poller_config,
"MetricsConfig": metrics_config
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ id }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

DELETE example

/*+ delete */
DELETE FROM awscc.lambda.event_source_mappings
WHERE
Identifier = '{{ id }}' AND
region = '{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

Additional Parameters

Mutable resources in the Cloud Control provider support additional optional parameters which can be supplied with INSERT, UPDATE, or DELETE operations. These include:

ParameterDescription
ClientToken
A unique identifier to ensure the idempotency of the resource request.This allows the provider to accurately distinguish between retries and new requests.
A client token is valid for 36 hours once used.
After that, a resource request with the same client token is treated as a new request.
If you do not specify a client token, one is generated for inclusion in the request.
RoleArn
The ARN of the IAM role used to perform this resource operation.The role specified must have the permissions required for this operation.
If you do not specify a role, a temporary session is created using your AWS user credentials.
TypeVersionId
For private resource types, the type version to use in this resource operation.If you do not specify a resource version, the default version is used.

Permissions

To operate on the event_source_mappings resource, the following permissions are required:

lambda:CreateEventSourceMapping,
lambda:GetEventSourceMapping,
lambda:TagResource,
kms:DescribeKey,
kms:GenerateDataKey,
kms:Decrypt