Class CfnEventSourceMapping

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IInspectable, IEnvironmentAware, IEventSourceMappingRef, ITaggableV2, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.121.0 (build d7af9b9)", date="2025-12-18T18:20:12.656Z") @Stability(Stable) public class CfnEventSourceMapping extends CfnResource implements IInspectable, IEventSourceMappingRef, ITaggableV2
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.

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")
                 .schemaRegistryConfig(SchemaRegistryConfigProperty.builder()
                         .accessConfigs(List.of(SchemaRegistryAccessConfigProperty.builder()
                                 .type("type")
                                 .uri("uri")
                                 .build()))
                         .eventRecordFormat("eventRecordFormat")
                         .schemaRegistryUri("schemaRegistryUri")
                         .schemaValidationConfigs(List.of(SchemaValidationConfigProperty.builder()
                                 .attribute("attribute")
                                 .build()))
                         .build())
                 .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"))
         .kmsKeyArn("kmsKeyArn")
         .loggingConfig(LoggingConfigProperty.builder()
                 .systemLogLevel("systemLogLevel")
                 .build())
         .maximumBatchingWindowInSeconds(123)
         .maximumRecordAgeInSeconds(123)
         .maximumRetryAttempts(123)
         .metricsConfig(MetricsConfigProperty.builder()
                 .metrics(List.of("metrics"))
                 .build())
         .parallelizationFactor(123)
         .provisionedPollerConfig(ProvisionedPollerConfigProperty.builder()
                 .maximumPollers(123)
                 .minimumPollers(123)
                 .pollerGroupName("pollerGroupName")
                 .build())
         .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")
                 .schemaRegistryConfig(SchemaRegistryConfigProperty.builder()
                         .accessConfigs(List.of(SchemaRegistryAccessConfigProperty.builder()
                                 .type("type")
                                 .uri("uri")
                                 .build()))
                         .eventRecordFormat("eventRecordFormat")
                         .schemaRegistryUri("schemaRegistryUri")
                         .schemaValidationConfigs(List.of(SchemaValidationConfigProperty.builder()
                                 .attribute("attribute")
                                 .build()))
                         .build())
                 .build())
         .sourceAccessConfigurations(List.of(SourceAccessConfigurationProperty.builder()
                 .type("type")
                 .uri("uri")
                 .build()))
         .startingPosition("startingPosition")
         .startingPositionTimestamp(123)
         .tags(List.of(CfnTag.builder()
                 .key("key")
                 .value("value")
                 .build()))
         .topics(List.of("topics"))
         .tumblingWindowInSeconds(123)
         .build();
 

See Also:
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String 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 software.constructs.Construct scope, @NotNull String id, @NotNull CfnEventSourceMappingProps props)
      Create a new AWS::Lambda::EventSourceMapping.

      Parameters:
      scope - Scope in which this resource is defined. This parameter is required.
      id - Construct identifier for this resource (unique in its scope). This parameter is required.
      props - Resource properties. This parameter is required.
  • Method Details

    • arnForEventSourceMapping

      @Stability(Stable) @NotNull public static String arnForEventSourceMapping(@NotNull IEventSourceMappingRef resource)
      Parameters:
      resource - This parameter is required.
    • isCfnEventSourceMapping

      @Stability(Stable) @NotNull public static Boolean isCfnEventSourceMapping(@NotNull Object x)
      Checks whether the given object is a CfnEventSourceMapping.

      Parameters:
      x - This parameter is required.
    • inspect

      @Stability(Stable) public void inspect(@NotNull TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface IInspectable
      Parameters:
      inspector - tree inspector to collect and process attributes. This parameter is required.
    • renderProperties

      @Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
      Overrides:
      renderProperties in class CfnResource
      Parameters:
      props - This parameter is required.
    • getAttrEventSourceMappingArn

      @Stability(Stable) @NotNull public String getAttrEventSourceMappingArn()
      The Amazon Resource Name (ARN) of the event source mapping.
    • getAttrId

      @Stability(Stable) @NotNull public String getAttrId()
      The event source mapping's ID.
    • getCdkTagManager

      @Stability(Stable) @NotNull public TagManager getCdkTagManager()
      Tag Manager which manages the tags for this resource.
      Specified by:
      getCdkTagManager in interface ITaggableV2
    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class CfnResource
    • getEventSourceMappingRef

      @Stability(Stable) @NotNull public EventSourceMappingReference getEventSourceMappingRef()
      A reference to a EventSourceMapping resource.
      Specified by:
      getEventSourceMappingRef in interface IEventSourceMappingRef
    • getFunctionName

      @Stability(Stable) @NotNull public String getFunctionName()
      The name or ARN of the Lambda function.
    • setFunctionName

      @Stability(Stable) public void setFunctionName(@NotNull String value)
      The name or ARN of the Lambda function.
    • getAmazonManagedKafkaEventSourceConfig

      @Stability(Stable) @Nullable public Object getAmazonManagedKafkaEventSourceConfig()
      Specific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source.

      Returns union: either IResolvable or CfnEventSourceMapping.AmazonManagedKafkaEventSourceConfigProperty

    • setAmazonManagedKafkaEventSourceConfig

      @Stability(Stable) public void setAmazonManagedKafkaEventSourceConfig(@Nullable IResolvable value)
      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

      @Stability(Stable) @Nullable public Number getBatchSize()
      The maximum number of records in each batch that Lambda pulls from your stream or queue and sends to your function.
    • setBatchSize

      @Stability(Stable) public void setBatchSize(@Nullable Number value)
      The maximum number of records in each batch that Lambda pulls from your stream or queue and sends to your function.
    • getBisectBatchOnFunctionError

      @Stability(Stable) @Nullable public Object getBisectBatchOnFunctionError()
      (Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry.

      Returns union: either Boolean or IResolvable

    • setBisectBatchOnFunctionError

      @Stability(Stable) public void setBisectBatchOnFunctionError(@Nullable Boolean value)
      (Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry.
    • setBisectBatchOnFunctionError

      @Stability(Stable) public void setBisectBatchOnFunctionError(@Nullable IResolvable value)
      (Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry.
    • getDestinationConfig

      @Stability(Stable) @Nullable public Object getDestinationConfig()
      (Kinesis, DynamoDB Streams, Amazon MSK, and self-managed Apache Kafka) A configuration object that specifies the destination of an event after Lambda processes it.

      Returns union: either IResolvable or CfnEventSourceMapping.DestinationConfigProperty

    • setDestinationConfig

      @Stability(Stable) public void setDestinationConfig(@Nullable IResolvable value)
      (Kinesis, DynamoDB Streams, Amazon MSK, and self-managed Apache Kafka) A configuration object that specifies the destination of an event after Lambda processes it.
    • setDestinationConfig

      @Stability(Stable) public void setDestinationConfig(@Nullable CfnEventSourceMapping.DestinationConfigProperty value)
      (Kinesis, DynamoDB Streams, Amazon MSK, and self-managed Apache Kafka) A configuration object that specifies the destination of an event after Lambda processes it.
    • getDocumentDbEventSourceConfig

      @Stability(Stable) @Nullable public Object getDocumentDbEventSourceConfig()
      Specific configuration settings for a DocumentDB event source.

      Returns union: either IResolvable or CfnEventSourceMapping.DocumentDBEventSourceConfigProperty

    • setDocumentDbEventSourceConfig

      @Stability(Stable) public void setDocumentDbEventSourceConfig(@Nullable IResolvable value)
      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

      @Stability(Stable) @Nullable public Object getEnabled()
      When true, the event source mapping is active.

      When false, Lambda pauses polling and invocation.

      Returns union: either Boolean or IResolvable

    • setEnabled

      @Stability(Stable) public void setEnabled(@Nullable Boolean value)
      When true, the event source mapping is active.

      When false, Lambda pauses polling and invocation.

    • setEnabled

      @Stability(Stable) public void setEnabled(@Nullable IResolvable value)
      When true, the event source mapping is active.

      When false, Lambda pauses polling and invocation.

    • getEventSourceArn

      @Stability(Stable) @Nullable public String getEventSourceArn()
      The Amazon Resource Name (ARN) of the event source.
    • setEventSourceArn

      @Stability(Stable) public void setEventSourceArn(@Nullable String value)
      The Amazon Resource Name (ARN) of the event source.
    • getFilterCriteria

      @Stability(Stable) @Nullable public Object getFilterCriteria()
      An object that defines the filter criteria that determine whether Lambda should process an event.

      Returns union: either IResolvable or CfnEventSourceMapping.FilterCriteriaProperty

    • setFilterCriteria

      @Stability(Stable) public void setFilterCriteria(@Nullable IResolvable value)
      An object that defines the filter criteria that determine whether Lambda should process an event.
    • 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.
    • getFunctionResponseTypes

      @Stability(Stable) @Nullable public List<String> getFunctionResponseTypes()
      (Kinesis, DynamoDB Streams, and SQS) A list of current response type enums applied to the event source mapping.
    • setFunctionResponseTypes

      @Stability(Stable) public void setFunctionResponseTypes(@Nullable List<String> value)
      (Kinesis, DynamoDB Streams, and SQS) A list of current response type enums applied to the event source mapping.
    • getKmsKeyArn

      @Stability(Stable) @Nullable public String getKmsKeyArn()
      The ARN of the AWS Key Management Service ( AWS ) customer managed key that Lambda uses to encrypt your function's filter criteria .
    • setKmsKeyArn

      @Stability(Stable) public void setKmsKeyArn(@Nullable String value)
      The ARN of the AWS Key Management Service ( AWS ) customer managed key that Lambda uses to encrypt your function's filter criteria .
    • getLoggingConfig

      @Stability(Stable) @Nullable public Object getLoggingConfig()
      The function's Amazon CloudWatch Logs configuration settings.

      Returns union: either IResolvable or CfnEventSourceMapping.LoggingConfigProperty

    • setLoggingConfig

      @Stability(Stable) public void setLoggingConfig(@Nullable IResolvable value)
      The function's Amazon CloudWatch Logs configuration settings.
    • setLoggingConfig

      @Stability(Stable) public void setLoggingConfig(@Nullable CfnEventSourceMapping.LoggingConfigProperty value)
      The function's Amazon CloudWatch Logs configuration settings.
    • getMaximumBatchingWindowInSeconds

      @Stability(Stable) @Nullable public Number getMaximumBatchingWindowInSeconds()
      The maximum amount of time, in seconds, that Lambda spends gathering records before invoking the function.
    • setMaximumBatchingWindowInSeconds

      @Stability(Stable) public void setMaximumBatchingWindowInSeconds(@Nullable Number value)
      The maximum amount of time, in seconds, that Lambda spends gathering records before invoking the function.
    • getMaximumRecordAgeInSeconds

      @Stability(Stable) @Nullable public Number getMaximumRecordAgeInSeconds()
      (Kinesis, DynamoDB Streams, Amazon MSK, and self-managed Apache Kafka) Discard records older than the specified age.
    • setMaximumRecordAgeInSeconds

      @Stability(Stable) public void setMaximumRecordAgeInSeconds(@Nullable Number value)
      (Kinesis, DynamoDB Streams, Amazon MSK, and self-managed Apache Kafka) Discard records older than the specified age.
    • getMaximumRetryAttempts

      @Stability(Stable) @Nullable public Number getMaximumRetryAttempts()
      (Kinesis, DynamoDB Streams, Amazon MSK, and self-managed Apache Kafka) Discard records after the specified number of retries.
    • setMaximumRetryAttempts

      @Stability(Stable) public void setMaximumRetryAttempts(@Nullable Number value)
      (Kinesis, DynamoDB Streams, Amazon MSK, and self-managed Apache Kafka) Discard records after the specified number of retries.
    • getMetricsConfig

      @Stability(Stable) @Nullable public Object getMetricsConfig()
      The metrics configuration for your event source.

      Returns union: either IResolvable or CfnEventSourceMapping.MetricsConfigProperty

    • setMetricsConfig

      @Stability(Stable) public void setMetricsConfig(@Nullable IResolvable value)
      The metrics configuration for your event source.
    • setMetricsConfig

      @Stability(Stable) public void setMetricsConfig(@Nullable CfnEventSourceMapping.MetricsConfigProperty value)
      The metrics configuration for your event source.
    • getParallelizationFactor

      @Stability(Stable) @Nullable public Number getParallelizationFactor()
      (Kinesis and DynamoDB Streams only) The number of batches to process concurrently from each shard.
    • setParallelizationFactor

      @Stability(Stable) public void setParallelizationFactor(@Nullable Number value)
      (Kinesis and DynamoDB Streams only) The number of batches to process concurrently from each shard.
    • getProvisionedPollerConfig

      @Stability(Stable) @Nullable public Object getProvisionedPollerConfig()
      (Amazon SQS, Amazon MSK, and self-managed Apache Kafka only) The provisioned mode configuration for the event source.

      Returns union: either IResolvable or CfnEventSourceMapping.ProvisionedPollerConfigProperty

    • setProvisionedPollerConfig

      @Stability(Stable) public void setProvisionedPollerConfig(@Nullable IResolvable value)
      (Amazon SQS, Amazon MSK, and self-managed Apache Kafka only) The provisioned mode configuration for the event source.
    • setProvisionedPollerConfig

      @Stability(Stable) public void setProvisionedPollerConfig(@Nullable CfnEventSourceMapping.ProvisionedPollerConfigProperty value)
      (Amazon SQS, Amazon MSK, and self-managed Apache Kafka only) The provisioned mode configuration for the event source.
    • getQueues

      @Stability(Stable) @Nullable public List<String> getQueues()
      (Amazon MQ) The name of the Amazon MQ broker destination queue to consume.
    • setQueues

      @Stability(Stable) public void setQueues(@Nullable List<String> value)
      (Amazon MQ) The name of the Amazon MQ broker destination queue to consume.
    • getScalingConfig

      @Stability(Stable) @Nullable public Object getScalingConfig()
      This property is for Amazon SQS event sources only.

      Returns union: either IResolvable or CfnEventSourceMapping.ScalingConfigProperty

    • setScalingConfig

      @Stability(Stable) public void setScalingConfig(@Nullable IResolvable value)
      This property is for Amazon SQS event sources only.
    • setScalingConfig

      @Stability(Stable) public void setScalingConfig(@Nullable CfnEventSourceMapping.ScalingConfigProperty value)
      This property is for Amazon SQS event sources only.
    • getSelfManagedEventSource

      @Stability(Stable) @Nullable public Object getSelfManagedEventSource()
      The self-managed Apache Kafka cluster for your event source.

      Returns union: either IResolvable or CfnEventSourceMapping.SelfManagedEventSourceProperty

    • setSelfManagedEventSource

      @Stability(Stable) public void setSelfManagedEventSource(@Nullable IResolvable value)
      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

      @Stability(Stable) @Nullable public Object getSelfManagedKafkaEventSourceConfig()
      Specific configuration settings for a self-managed Apache Kafka event source.

      Returns union: either IResolvable or CfnEventSourceMapping.SelfManagedKafkaEventSourceConfigProperty

    • setSelfManagedKafkaEventSourceConfig

      @Stability(Stable) public void setSelfManagedKafkaEventSourceConfig(@Nullable IResolvable value)
      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

      @Stability(Stable) @Nullable public Object getSourceAccessConfigurations()
      An array of the authentication protocol, VPC components, or virtual host to secure and define your event source.

      Returns union: either IResolvable or Listinvalid input: '<'either IResolvable or CfnEventSourceMapping.SourceAccessConfigurationProperty>

    • setSourceAccessConfigurations

      @Stability(Stable) public void setSourceAccessConfigurations(@Nullable IResolvable value)
      An array of the authentication protocol, VPC components, or virtual host to secure and define your event source.
    • setSourceAccessConfigurations

      @Stability(Stable) public void setSourceAccessConfigurations(@Nullable List<Object> value)
      An array of the authentication protocol, VPC components, or virtual host to secure and define your event source.
    • getStartingPosition

      @Stability(Stable) @Nullable public String getStartingPosition()
      The position in a stream from which to start reading.

      Required for Amazon Kinesis and Amazon DynamoDB.

    • setStartingPosition

      @Stability(Stable) public void setStartingPosition(@Nullable String value)
      The position in a stream from which to start reading.

      Required for Amazon Kinesis and Amazon DynamoDB.

    • getStartingPositionTimestamp

      @Stability(Stable) @Nullable public Number getStartingPositionTimestamp()
      With StartingPosition set to AT_TIMESTAMP , the time from which to start reading, in Unix time seconds.
    • setStartingPositionTimestamp

      @Stability(Stable) public void setStartingPositionTimestamp(@Nullable Number value)
      With StartingPosition set to AT_TIMESTAMP , the time from which to start reading, in Unix time seconds.
    • getTags

      @Stability(Stable) @Nullable public List<CfnTag> getTags()
      A list of tags to add to the event source mapping.
    • setTags

      @Stability(Stable) public void setTags(@Nullable List<CfnTag> value)
      A list of tags to add to the event source mapping.
    • getTopics

      @Stability(Stable) @Nullable public List<String> getTopics()
      The name of the Kafka topic.
    • setTopics

      @Stability(Stable) public void setTopics(@Nullable List<String> value)
      The name of the Kafka topic.
    • getTumblingWindowInSeconds

      @Stability(Stable) @Nullable public Number getTumblingWindowInSeconds()
      (Kinesis and DynamoDB Streams only) The duration in seconds of a processing window for DynamoDB and Kinesis Streams event sources.
    • setTumblingWindowInSeconds

      @Stability(Stable) public void setTumblingWindowInSeconds(@Nullable Number value)
      (Kinesis and DynamoDB Streams only) The duration in seconds of a processing window for DynamoDB and Kinesis Streams event sources.