Class CfnEventSourceMapping
- All Implemented Interfaces:
IConstruct,IDependable,IInspectable,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct
AWS::Lambda::EventSourceMapping.
The AWS::Lambda::EventSourceMapping resource 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. 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
Example:
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.lambda.*;
CfnEventSourceMapping cfnEventSourceMapping = CfnEventSourceMapping.Builder.create(this, "MyCfnEventSourceMapping")
.functionName("functionName")
// the properties below are optional
.amazonManagedKafkaEventSourceConfig(AmazonManagedKafkaEventSourceConfigProperty.builder()
.consumerGroupId("consumerGroupId")
.build())
.batchSize(123)
.bisectBatchOnFunctionError(false)
.destinationConfig(DestinationConfigProperty.builder()
.onFailure(OnFailureProperty.builder()
.destination("destination")
.build())
.build())
.documentDbEventSourceConfig(DocumentDBEventSourceConfigProperty.builder()
.collectionName("collectionName")
.databaseName("databaseName")
.fullDocument("fullDocument")
.build())
.enabled(false)
.eventSourceArn("eventSourceArn")
.filterCriteria(FilterCriteriaProperty.builder()
.filters(List.of(FilterProperty.builder()
.pattern("pattern")
.build()))
.build())
.functionResponseTypes(List.of("functionResponseTypes"))
.maximumBatchingWindowInSeconds(123)
.maximumRecordAgeInSeconds(123)
.maximumRetryAttempts(123)
.parallelizationFactor(123)
.queues(List.of("queues"))
.scalingConfig(ScalingConfigProperty.builder()
.maximumConcurrency(123)
.build())
.selfManagedEventSource(SelfManagedEventSourceProperty.builder()
.endpoints(EndpointsProperty.builder()
.kafkaBootstrapServers(List.of("kafkaBootstrapServers"))
.build())
.build())
.selfManagedKafkaEventSourceConfig(SelfManagedKafkaEventSourceConfigProperty.builder()
.consumerGroupId("consumerGroupId")
.build())
.sourceAccessConfigurations(List.of(SourceAccessConfigurationProperty.builder()
.type("type")
.uri("uri")
.build()))
.startingPosition("startingPosition")
.startingPositionTimestamp(123)
.topics(List.of("topics"))
.tumblingWindowInSeconds(123)
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceSpecific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source.static final classA fluent builder forCfnEventSourceMapping.static interfaceA configuration object that specifies the destination of an event after Lambda processes it.static interfaceSpecific configuration settings for a DocumentDB event source.static interfaceThe list of bootstrap servers for your Kafka brokers in the following format:"KafkaBootstrapServers": ["abc.xyz.com:xxxx","abc2.xyz.com:xxxx"].static interfaceAn object that contains the filters for an event source.static interfaceA structure within aFilterCriteriaobject that defines an event filtering pattern.static interfaceA destination for events that failed processing.static interface(Amazon SQS only) The scaling configuration for the event source.static interfaceThe self-managed Apache Kafka cluster for your event source.static interfaceSpecific configuration settings for a self-managed Apache Kafka event source.static interfaceAn array of the authentication protocol, VPC components, or virtual host to secure and define your event source.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.core.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionCfnEventSourceMapping(Construct scope, String id, CfnEventSourceMappingProps props) Create a newAWS::Lambda::EventSourceMapping.protectedCfnEventSourceMapping(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCfnEventSourceMapping(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionSpecific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source.The event source mapping's ID.The maximum number of records in each batch that Lambda pulls from your stream or queue and sends to your function.(Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry.(Kinesis and DynamoDB Streams only) An Amazon SQS queue or Amazon SNS topic destination for discarded records.Specific configuration settings for a DocumentDB event source.When true, the event source mapping is active.The Amazon Resource Name (ARN) of the event source.An object that defines the filter criteria that determine whether Lambda should process an event.The name of the Lambda function.(Streams and SQS) A list of current response type enums applied to the event source mapping.The maximum amount of time, in seconds, that Lambda spends gathering records before invoking the function.(Kinesis and DynamoDB Streams only) Discard records older than the specified age.(Kinesis and DynamoDB Streams only) Discard records after the specified number of retries.(Kinesis and DynamoDB Streams only) The number of batches to process concurrently from each shard.(Amazon MQ) The name of the Amazon MQ broker destination queue to consume.(Amazon SQS only) The scaling configuration for the event source.The self-managed Apache Kafka cluster for your event source.Specific configuration settings for a self-managed Apache Kafka event source.An array of the authentication protocol, VPC components, or virtual host to secure and define your event source.The position in a stream from which to start reading.WithStartingPositionset toAT_TIMESTAMP, the time from which to start reading, in Unix time seconds.The name of the Kafka topic.(Kinesis and DynamoDB Streams only) The duration in seconds of a processing window for DynamoDB and Kinesis Streams event sources.voidinspect(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties(Map<String, Object> props) voidSpecific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source.voidsetAmazonManagedKafkaEventSourceConfig(CfnEventSourceMapping.AmazonManagedKafkaEventSourceConfigProperty value) Specific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source.voidsetBatchSize(Number value) The maximum number of records in each batch that Lambda pulls from your stream or queue and sends to your function.void(Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry.void(Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry.voidsetDestinationConfig(IResolvable value) (Kinesis and DynamoDB Streams only) An Amazon SQS queue or Amazon SNS topic destination for discarded records.void(Kinesis and DynamoDB Streams only) An Amazon SQS queue or Amazon SNS topic destination for discarded records.voidSpecific configuration settings for a DocumentDB event source.voidSpecific configuration settings for a DocumentDB event source.voidsetEnabled(Boolean value) When true, the event source mapping is active.voidsetEnabled(IResolvable value) When true, the event source mapping is active.voidsetEventSourceArn(String value) The Amazon Resource Name (ARN) of the event source.voidsetFilterCriteria(IResolvable value) An object that defines the filter criteria that determine whether Lambda should process an event.voidAn object that defines the filter criteria that determine whether Lambda should process an event.voidsetFunctionName(String value) The name of the Lambda function.voidsetFunctionResponseTypes(List<String> value) (Streams and SQS) A list of current response type enums applied to the event source mapping.voidThe maximum amount of time, in seconds, that Lambda spends gathering records before invoking the function.void(Kinesis and DynamoDB Streams only) Discard records older than the specified age.voidsetMaximumRetryAttempts(Number value) (Kinesis and DynamoDB Streams only) Discard records after the specified number of retries.voidsetParallelizationFactor(Number value) (Kinesis and DynamoDB Streams only) The number of batches to process concurrently from each shard.void(Amazon MQ) The name of the Amazon MQ broker destination queue to consume.voidsetScalingConfig(IResolvable value) (Amazon SQS only) The scaling configuration for the event source.void(Amazon SQS only) The scaling configuration for the event source.voidThe self-managed Apache Kafka cluster for your event source.voidThe self-managed Apache Kafka cluster for your event source.voidSpecific configuration settings for a self-managed Apache Kafka event source.voidsetSelfManagedKafkaEventSourceConfig(CfnEventSourceMapping.SelfManagedKafkaEventSourceConfigProperty value) Specific configuration settings for a self-managed Apache Kafka event source.voidsetSourceAccessConfigurations(List<Object> value) An array of the authentication protocol, VPC components, or virtual host to secure and define your event source.voidAn array of the authentication protocol, VPC components, or virtual host to secure and define your event source.voidsetStartingPosition(String value) The position in a stream from which to start reading.voidWithStartingPositionset toAT_TIMESTAMP, the time from which to start reading, in Unix time seconds.voidThe name of the Kafka topic.voidsetTumblingWindowInSeconds(Number value) (Kinesis and DynamoDB Streams only) The duration in seconds of a processing window for DynamoDB and Kinesis Streams event sources.Methods inherited from class software.amazon.awscdk.core.CfnResource
addDeletionOverride, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, isCfnResource, shouldSynthesize, toString, validatePropertiesMethods inherited from class software.amazon.awscdk.core.CfnRefElement
getRefMethods inherited from class software.amazon.awscdk.core.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdMethods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validateMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnEventSourceMapping
protected CfnEventSourceMapping(software.amazon.jsii.JsiiObjectRef objRef) -
CfnEventSourceMapping
protected CfnEventSourceMapping(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnEventSourceMapping
@Stability(Stable) public CfnEventSourceMapping(@NotNull Construct scope, @NotNull String id, @NotNull CfnEventSourceMappingProps props) Create a newAWS::Lambda::EventSourceMapping.- Parameters:
scope-- scope in which this resource is defined.
id-- scoped id of the resource.
props-- resource properties.
-
-
Method Details
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspectin interfaceIInspectable- Parameters:
inspector-- tree inspector to collect and process attributes.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderPropertiesin classCfnResource- Parameters:
props- This parameter is required.
-
getAttrId
The event source mapping's ID. -
getCfnProperties
- Overrides:
getCfnPropertiesin classCfnResource
-
getFunctionName
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.
- Function ARN –
-
setFunctionName
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.
- Function ARN –
-
getAmazonManagedKafkaEventSourceConfig
Specific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source. -
setAmazonManagedKafkaEventSourceConfig
Specific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source. -
setAmazonManagedKafkaEventSourceConfig
@Stability(Stable) public void setAmazonManagedKafkaEventSourceConfig(@Nullable CfnEventSourceMapping.AmazonManagedKafkaEventSourceConfigProperty value) Specific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source. -
getBatchSize
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.
-
setBatchSize
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.
-
getBisectBatchOnFunctionError
(Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry.The default value is false.
-
setBisectBatchOnFunctionError
(Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry.The default value is false.
-
setBisectBatchOnFunctionError
(Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry.The default value is false.
-
getDestinationConfig
(Kinesis and DynamoDB Streams only) An Amazon SQS queue or Amazon SNS topic destination for discarded records. -
setDestinationConfig
(Kinesis and DynamoDB Streams only) An Amazon SQS queue or Amazon SNS topic destination for discarded records. -
setDestinationConfig
@Stability(Stable) public void setDestinationConfig(@Nullable CfnEventSourceMapping.DestinationConfigProperty value) (Kinesis and DynamoDB Streams only) An Amazon SQS queue or Amazon SNS topic destination for discarded records. -
getDocumentDbEventSourceConfig
Specific configuration settings for a DocumentDB event source. -
setDocumentDbEventSourceConfig
Specific configuration settings for a DocumentDB event source. -
setDocumentDbEventSourceConfig
@Stability(Stable) public void setDocumentDbEventSourceConfig(@Nullable CfnEventSourceMapping.DocumentDBEventSourceConfigProperty value) Specific configuration settings for a DocumentDB event source. -
getEnabled
When true, the event source mapping is active. When false, Lambda pauses polling and invocation.Default: True
-
setEnabled
When true, the event source mapping is active. When false, Lambda pauses polling and invocation.Default: True
-
setEnabled
When true, the event source mapping is active. When false, Lambda pauses polling and invocation.Default: True
-
getEventSourceArn
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.
- Amazon MQ – The ARN of the broker.
- Amazon DocumentDB – The ARN of the DocumentDB change stream.
-
setEventSourceArn
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.
- Amazon MQ – The ARN of the broker.
- Amazon DocumentDB – The ARN of the DocumentDB change stream.
-
getFilterCriteria
An object that defines the filter criteria that determine whether Lambda should process an event.For more information, see Lambda event filtering .
-
setFilterCriteria
An object that defines the filter criteria that determine whether Lambda should process an event.For more information, see Lambda event filtering .
-
setFilterCriteria
@Stability(Stable) public void setFilterCriteria(@Nullable CfnEventSourceMapping.FilterCriteriaProperty value) An object that defines the filter criteria that determine whether Lambda should process an event.For more information, see Lambda event filtering .
-
getFunctionResponseTypes
(Streams and SQS) A list of current response type enums applied to the event source mapping.Valid Values:
ReportBatchItemFailures -
setFunctionResponseTypes
(Streams and SQS) A list of current response type enums applied to the event source mapping.Valid Values:
ReportBatchItemFailures -
getMaximumBatchingWindowInSeconds
The maximum amount of time, in seconds, that Lambda spends gathering records before invoking the function.Default ( Kinesis , DynamoDB , Amazon SQS event sources) : 0
Default ( Amazon MSK , Kafka, Amazon MQ , Amazon DocumentDB event sources) : 500 ms
Related setting: For Amazon SQS event sources, when you set
BatchSizeto a value greater than 10, you must setMaximumBatchingWindowInSecondsto at least 1. -
setMaximumBatchingWindowInSeconds
The maximum amount of time, in seconds, that Lambda spends gathering records before invoking the function.Default ( Kinesis , DynamoDB , Amazon SQS event sources) : 0
Default ( Amazon MSK , Kafka, Amazon MQ , Amazon DocumentDB event sources) : 500 ms
Related setting: For Amazon SQS event sources, when you set
BatchSizeto a value greater than 10, you must setMaximumBatchingWindowInSecondsto at least 1. -
getMaximumRecordAgeInSeconds
(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
-
setMaximumRecordAgeInSeconds
(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
-
getMaximumRetryAttempts
(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.
-
setMaximumRetryAttempts
(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.
-
getParallelizationFactor
(Kinesis and DynamoDB Streams only) The number of batches to process concurrently from each shard.The default value is 1.
-
setParallelizationFactor
(Kinesis and DynamoDB Streams only) The number of batches to process concurrently from each shard.The default value is 1.
-
getQueues
(Amazon MQ) The name of the Amazon MQ broker destination queue to consume. -
setQueues
(Amazon MQ) The name of the Amazon MQ broker destination queue to consume. -
getScalingConfig
(Amazon SQS only) The scaling configuration for the event source.For more information, see Configuring maximum concurrency for Amazon SQS event sources .
-
setScalingConfig
(Amazon SQS only) The scaling configuration for the event source.For more information, see Configuring maximum concurrency for Amazon SQS event sources .
-
setScalingConfig
@Stability(Stable) public void setScalingConfig(@Nullable CfnEventSourceMapping.ScalingConfigProperty value) (Amazon SQS only) The scaling configuration for the event source.For more information, see Configuring maximum concurrency for Amazon SQS event sources .
-
getSelfManagedEventSource
The self-managed Apache Kafka cluster for your event source. -
setSelfManagedEventSource
The self-managed Apache Kafka cluster for your event source. -
setSelfManagedEventSource
@Stability(Stable) public void setSelfManagedEventSource(@Nullable CfnEventSourceMapping.SelfManagedEventSourceProperty value) The self-managed Apache Kafka cluster for your event source. -
getSelfManagedKafkaEventSourceConfig
Specific configuration settings for a self-managed Apache Kafka event source. -
setSelfManagedKafkaEventSourceConfig
Specific configuration settings for a self-managed Apache Kafka event source. -
setSelfManagedKafkaEventSourceConfig
@Stability(Stable) public void setSelfManagedKafkaEventSourceConfig(@Nullable CfnEventSourceMapping.SelfManagedKafkaEventSourceConfigProperty value) Specific configuration settings for a self-managed Apache Kafka event source. -
getSourceAccessConfigurations
An array of the authentication protocol, VPC components, or virtual host to secure and define your event source. -
setSourceAccessConfigurations
An array of the authentication protocol, VPC components, or virtual host to secure and define your event source. -
setSourceAccessConfigurations
An array of the authentication protocol, VPC components, or virtual host to secure and define your event source. -
getStartingPosition
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.
-
setStartingPosition
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.
-
getStartingPositionTimestamp
WithStartingPositionset toAT_TIMESTAMP, the time from which to start reading, in Unix time seconds. -
setStartingPositionTimestamp
WithStartingPositionset toAT_TIMESTAMP, the time from which to start reading, in Unix time seconds. -
getTopics
The name of the Kafka topic. -
setTopics
The name of the Kafka topic. -
getTumblingWindowInSeconds
(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.
-
setTumblingWindowInSeconds
(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.
-