Skip to content

AWS::Lambda::EventSourceMapping

The AWS::Lambda::EventSourceMapping resource creates a mapping between an event source and an LAMlong function.

Generated by cfn-typegen --out cfn_types AWS::Lambda::EventSourceMapping into cfn_types/lambda_.py:

# Generated by cfn-typegen from the CloudFormation registry schemas. Do not edit.
# fmt: off
# ruff: noqa
"""AWS::Lambda resources."""

from collections.abc import Sequence
from typing import Any, Literal, NotRequired, Unpack
from typing_extensions import TypedDict
from cfn_typed.base import DeletionPolicy, DependsOn, ResourceAttrs, Tag, UpdateReplacePolicy, build
from cfn_typed.intrinsics import Expr


_c0="[a-zA-Z0-9-\\/*:_+=.@-]*"
_c1="arn:(aws[a-zA-Z0-9-]*):([a-zA-Z0-9\\-])+:((eusc-)?[a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\\d{1})?:(\\d{12})?:(.*)"
_c2={'P':{'SchemaValidationConfigs':{'i':1,'I':2,'T':{'P':{'Attribute':{'e':["KEY","VALUE"]}}}},'SchemaRegistryURI':{'p':"[a-zA-Z0-9-/*:_+=.@-]*",'l':1,'L':10000},'EventRecordFormat':{'e':["JSON","SOURCE"]},'AccessConfigs':{'I':2,'T':{'P':{'Type':{'e':["BASIC_AUTH","CLIENT_CERTIFICATE_TLS_AUTH","SERVER_ROOT_CA_CERTIFICATE","OAUTHBEARER_AUTH"]},'URI':{'p':_c1,'l':1,'L':10000}}}}}}
CONSTRAINTS:dict[str,Any]={
'AWS::Lambda::EventSourceMapping':{'StartingPosition':{'p':"(LATEST|TRIM_HORIZON|AT_TIMESTAMP)+",'l':6,'L':12},'SelfManagedEventSource':{'P':{'Endpoints':{'P':{'KafkaBootstrapServers':{'i':1,'I':10,'T':{'p':"^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9]):[0-9]{1,5}",'l':1,'L':300}}}}}},'ParallelizationFactor':{'m':1,'M':10},'FilterCriteria':{'P':{'Filters':{'i':1,'I':20,'T':{'P':{'Pattern':{'p':".*",'l':0,'L':4096}}}}}},'ProvisionedPollerConfig':{'P':{'PollerGroupName':{'l':0,'L':128},'MinimumPollers':{'m':1,'M':200},'MaximumPollers':{'m':1,'M':10000}}},'MetricsConfig':{'P':{'Metrics':{'i':0,'I':3,'T':{'e':["EventCount","ErrorCount","KafkaMetrics"]}}}},'FunctionName':{'p':"(arn:(aws[a-zA-Z-]*)?:lambda:)?((eusc-)?[a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\\d{1}:)?(\\d{12}:)?(function:)?([a-zA-Z0-9-_]+)(:(\\$LATEST(\\.PUBLISHED)?|[a-zA-Z0-9-_]+))?",'l':1,'L':140},'DestinationConfig':{'P':{'OnFailure':{'P':{'Destination':{'p':"^$|kafka://([^.]([a-zA-Z0-9\\-_.]{0,248}))|arn:(aws[a-zA-Z0-9-]*):([a-zA-Z0-9\\-])+:((eusc-)?[a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\\d{1})?:(\\d{12})?:(.*)",'l':12,'L':1024}}}}},'KmsKeyArn':{'p':"(arn:(aws[a-zA-Z-]*)?:[a-z0-9-.]+:.*)|()",'l':12,'L':2048},'AmazonManagedKafkaEventSourceConfig':{'P':{'ConsumerGroupId':{'p':_c0,'l':1,'L':200},'SchemaRegistryConfig':_c2}},'SourceAccessConfigurations':{'i':1,'I':29,'T':{'P':{'Type':{'e':["BASIC_AUTH","VPC_SUBNET","VPC_SECURITY_GROUP","SASL_SCRAM_512_AUTH","SASL_SCRAM_256_AUTH","VIRTUAL_HOST","CLIENT_CERTIFICATE_TLS_AUTH","SERVER_ROOT_CA_CERTIFICATE","OAUTHBEARER_AUTH","OAUTHBEARER_SCOPE","OAUTHBEARER_AUDIENCE","OAUTHBEARER_LOGICAL_CLUSTER","OAUTHBEARER_IDENTITY_POOL","IAM_AUTH","IAM_OAUTHBEARER_AUTH"]},'URI':{'p':_c0,'l':1,'L':200}}}},'Tags':{'T':{'P':{'Value':{'l':0,'L':256},'Key':{'l':1,'L':128}}}},'MaximumBatchingWindowInSeconds':{'m':0,'M':300},'BatchSize':{'m':1,'M':10000},'MaximumRetryAttempts':{'m':-1,'M':10000},'Topics':{'i':1,'I':1,'T':{'p':"^[^.]([a-zA-Z0-9\\-_.]+)",'l':1,'L':249}},'ScalingConfig':{'P':{'MaximumConcurrency':{'m':2,'M':1000}}},'EventSourceArn':{'p':_c1,'l':12,'L':1024},'SelfManagedKafkaEventSourceConfig':{'P':{'ConsumerGroupId':{'p':_c0,'l':1,'L':200},'SchemaRegistryConfig':_c2,'ConsumptionMode':{'e':["Stream","Queue"]}}},'DocumentDBEventSourceConfig':{'P':{'FullDocument':{'e':["UpdateLookup","Default"]},'CollectionName':{'l':1,'L':57},'DatabaseName':{'l':1,'L':63}}},'TumblingWindowInSeconds':{'m':0,'M':900},'EventSourceMappingArn':{'p':"arn:(aws[a-zA-Z-]*)?:lambda:(eusc-)?[a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\\d{1}:\\d{12}:event-source-mapping:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}",'l':85,'L':120},'MaximumRecordAgeInSeconds':{'m':-1,'M':604800},'LoggingConfig':{'P':{'SystemLogLevel':{'e':["DEBUG","INFO","WARN"]}}},'Queues':{'i':1,'I':1,'T':{'p':"[\\s\\S]*",'l':1,'L':1000}},'Id':{'p':"[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}",'l':36,'L':36},'FunctionResponseTypes':{'l':0,'L':1,'T':{'e':["ReportBatchItemFailures"]}}},
}


ATTRIBUTES:dict[str,Any]={"AWS::Lambda::EventSourceMapping":["EventSourceMappingArn","Id"]}


RULES:dict[str,Any]={}
Nested types (20)

These are defined above the properties in the generated module.

class EventSourceMappingEndpoints(TypedDict, closed=True):
    'The list of bootstrap servers for your Kafka brokers in the following format: ``"KafkaBootstrapServers": ["abc.xyz.com:xxxx","abc2.xyz.com:xxxx"]``.'
    KafkaBootstrapServers: NotRequired[Expr[list[Expr[str]]]]
    'The list of bootstrap servers for your Kafka brokers in the following format: ``"KafkaBootstrapServers": ["abc.xyz.com:xxxx","abc2.xyz.com:xxxx"]``.'


class EventSourceMappingSelfManagedEventSource(TypedDict, closed=True):
    'The self-managed Apache Kafka cluster for your event source.'
    Endpoints: NotRequired[Expr[EventSourceMappingEndpoints]]
    'The list of bootstrap servers for your Kafka brokers in the following format: ``"KafkaBootstrapServers": ["abc.xyz.com:xxxx","abc2.xyz.com:xxxx"]``.'


class EventSourceMappingFilter(TypedDict, closed=True):
    'A structure within a ``FilterCriteria`` object that defines an event filtering pattern.'
    Pattern: NotRequired[Expr[str]]
    'A filter pattern.'


class EventSourceMappingFilterCriteria(TypedDict, closed=True):
    'An object that contains the filters for an event source.'
    Filters: NotRequired[Expr[Sequence[Expr[EventSourceMappingFilter]]]]
    'A list of filters.'


class EventSourceMappingProvisionedPollerConfig(TypedDict, closed=True):
    'The [provisioned mode](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventsourcemapping.html#invocation-eventsourcemapping-provisioned-mode) config...'
    PollerGroupName: NotRequired[Expr[str]]
    '(Amazon MSK and self-managed Apache Kafka) The name of the provisioned poller group.'
    MinimumPollers: NotRequired[Expr[int]]
    'The minimum number of event pollers this event source can scale down to.'
    MaximumPollers: NotRequired[Expr[int]]
    'The maximum number of event pollers this event source can scale up to.'


class EventSourceMappingMetricsConfig(TypedDict, closed=True):
    'The metrics configuration for your event source.'
    Metrics: NotRequired[Expr[list[Expr[str]]]]
    'The metrics you want your event source mapping to produce, including ``EventCount``, ``ErrorCount``, ``KafkaMetrics``.'


class EventSourceMappingOnFailure(TypedDict, closed=True):
    'A destination for events that failed processing.'
    Destination: NotRequired[Expr[str]]
    'The Amazon Resource Name (ARN) of the destination resource.'


class EventSourceMappingDestinationConfig(TypedDict, closed=True):
    'A configuration object that specifies the destination of an event after Lambda processes it.'
    OnFailure: NotRequired[Expr[EventSourceMappingOnFailure]]
    'The destination configuration for failed invocations.'


class EventSourceMappingSchemaValidationConfig(TypedDict, closed=True):
    'Specific schema validation configuration settings that tell Lambda the message attributes you want to validate and filter using your schema registry.'
    Attribute: NotRequired[Expr[str]]
    'The attributes you want your schema registry to validate and filter for.'


class EventSourceMappingSchemaRegistryAccessConfig(TypedDict, closed=True):
    'Specific access configuration settings that tell Lambda how to authenticate with your schema registry.'
    Type: NotRequired[Expr[str]]
    'The type of authentication Lambda uses to access your schema registry.'
    URI: NotRequired[Expr[str]]
    'The URI of the secret (Secrets Manager secret ARN) to authenticate with your schema registry.'


class EventSourceMappingSchemaRegistryConfig(TypedDict, closed=True):
    'Specific configuration settings for a Kafka schema registry.'
    SchemaValidationConfigs: NotRequired[Expr[Sequence[Expr[EventSourceMappingSchemaValidationConfig]]]]
    'An array of schema validation configuration objects, which tell Lambda the message attributes you want to validate and filter using your schema registry.'
    SchemaRegistryURI: NotRequired[Expr[str]]
    'The URI for your schema registry.'
    EventRecordFormat: NotRequired[Expr[str]]
    'The record format that Lambda delivers to your function after schema validation.'
    AccessConfigs: NotRequired[Expr[Sequence[Expr[EventSourceMappingSchemaRegistryAccessConfig]]]]
    'An array of access configuration objects that tell Lambda how to authenticate with your schema registry.'


class EventSourceMappingAmazonManagedKafkaEventSourceConfig(TypedDict, closed=True):
    'Specific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source.'
    ConsumerGroupId: NotRequired[Expr[str]]
    'The identifier for the Kafka consumer group to join.'
    SchemaRegistryConfig: NotRequired[Expr[EventSourceMappingSchemaRegistryConfig]]
    'Specific configuration settings for a Kafka schema registry.'


class EventSourceMappingSourceAccessConfiguration(TypedDict, closed=True):
    'An array of the authentication protocol, VPC components, or virtual host to secure and define your event source.'
    Type: NotRequired[Expr[str]]
    'The type of authentication protocol, VPC components, or virtual host for your event source.'
    URI: NotRequired[Expr[str]]
    'The value for your chosen configuration in ``Type``.'


class EventSourceMappingScalingConfig(TypedDict, closed=True):
    '(Amazon SQS only) The scaling configuration for the event source.'
    MaximumConcurrency: NotRequired[Expr[int]]
    'Limits the number of concurrent instances that the SQS event source can invoke.'


class EventSourceMappingSelfManagedKafkaEventSourceConfig(TypedDict, closed=True):
    'Specific configuration settings for a self-managed Apache Kafka event source.'
    ConsumerGroupId: NotRequired[Expr[str]]
    'The identifier for the Kafka consumer group to join.'
    SchemaRegistryConfig: NotRequired[Expr[EventSourceMappingSchemaRegistryConfig]]
    'Specific configuration settings for a Kafka schema registry.'
    ConsumptionMode: NotRequired[Expr[str]]


class EventSourceMappingDocumentDBEventSourceConfig(TypedDict, closed=True):
    'Specific configuration settings for a DocumentDB event source.'
    FullDocument: NotRequired[Expr[str]]
    'Determines what DocumentDB sends to your event stream during document update operations.'
    CollectionName: NotRequired[Expr[str]]
    'The name of the collection to consume within the database.'
    DatabaseName: NotRequired[Expr[str]]
    'The name of the database to consume within the DocumentDB cluster.'


class EventSourceMappingLoggingConfig(TypedDict, closed=True):
    "The function's Amazon CloudWatch Logs configuration settings."
    SystemLogLevel: NotRequired[Expr[str]]
    'Set this property to filter the system logs for your function that Lambda sends to CloudWatch.'


class EventSourceMappingProps(TypedDict, closed=True):
    'The ``AWS::Lambda::EventSourceMapping`` resource creates a mapping between an event source and an LAMlong function.'
    StartingPosition: NotRequired[Expr[str]]
    'The position in a stream from which to start reading.'
    SelfManagedEventSource: NotRequired[Expr[EventSourceMappingSelfManagedEventSource]]
    'The self-managed Apache Kafka cluster for your event source.'
    ParallelizationFactor: NotRequired[Expr[int]]
    '(Kinesis and DynamoDB Streams only) The number of batches to process concurrently from each shard.'
    FilterCriteria: NotRequired[Expr[EventSourceMappingFilterCriteria]]
    'An object that defines the filter criteria that determine whether Lambda should process an event.'
    ProvisionedPollerConfig: NotRequired[Expr[EventSourceMappingProvisionedPollerConfig]]
    '(Amazon SQS, Amazon MSK, and self-managed Apache Kafka only) The provisioned mode configuration for the event source.'
    MetricsConfig: NotRequired[Expr[EventSourceMappingMetricsConfig]]
    'The metrics configuration for your event source.'
    FunctionName: Expr[str]
    'The name or ARN of the Lambda function.'
    DestinationConfig: NotRequired[Expr[EventSourceMappingDestinationConfig]]
    '(Kinesis, DynamoDB Streams, Amazon MSK, and self-managed Apache Kafka) A configuration object that specifies the destination of an event after Lambda process...'
    KmsKeyArn: NotRequired[Expr[str]]
    "The ARN of the KMSlong (KMS) customer managed key that Lambda uses to encrypt your function's [filter criteria](https://docs.aws.amazon.com/lambda/latest/dg/..."
    AmazonManagedKafkaEventSourceConfig: NotRequired[Expr[EventSourceMappingAmazonManagedKafkaEventSourceConfig]]
    'Specific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source.'
    SourceAccessConfigurations: NotRequired[Expr[Sequence[Expr[EventSourceMappingSourceAccessConfiguration]]]]
    'An array of the authentication protocol, VPC components, or virtual host to secure and define your event source.'
    Tags: NotRequired[Expr[Sequence[Expr[Tag]]]]
    'A list of tags to add to the event source mapping.'
    MaximumBatchingWindowInSeconds: NotRequired[Expr[int]]
    'The maximum amount of time, in seconds, that Lambda spends gathering records before invoking the function.'
    BatchSize: NotRequired[Expr[int]]
    'The maximum number of records in each batch that Lambda pulls from your stream or queue and sends to your function.'
    MaximumRetryAttempts: NotRequired[Expr[int]]
    '(Kinesis, DynamoDB Streams, Amazon MSK, and self-managed Apache Kafka) Discard records after the specified number of retries.'
    Topics: NotRequired[Expr[list[Expr[str]]]]
    'The name of the Kafka topic.'
    ScalingConfig: NotRequired[Expr[EventSourceMappingScalingConfig]]
    'This property is for Amazon SQS event sources only.'
    Enabled: NotRequired[Expr[bool]]
    'When true, the event source mapping is active.'
    EventSourceArn: NotRequired[Expr[str]]
    'The Amazon Resource Name (ARN) of the event source.'
    SelfManagedKafkaEventSourceConfig: NotRequired[Expr[EventSourceMappingSelfManagedKafkaEventSourceConfig]]
    'Specific configuration settings for a self-managed Apache Kafka event source.'
    DocumentDBEventSourceConfig: NotRequired[Expr[EventSourceMappingDocumentDBEventSourceConfig]]
    'Specific configuration settings for a DocumentDB event source.'
    TumblingWindowInSeconds: NotRequired[Expr[int]]
    '(Kinesis and DynamoDB Streams only) The duration in seconds of a processing window for DynamoDB and Kinesis Streams event sources.'
    BisectBatchOnFunctionError: NotRequired[Expr[bool]]
    '(Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry.'
    MaximumRecordAgeInSeconds: NotRequired[Expr[int]]
    '(Kinesis, DynamoDB Streams, Amazon MSK, and self-managed Apache Kafka) Discard records older than the specified age.'
    StartingPositionTimestamp: NotRequired[Expr[float]]
    'With ``StartingPosition`` set to ``AT_TIMESTAMP``, the time from which to start reading, in Unix time seconds.'
    LoggingConfig: NotRequired[Expr[EventSourceMappingLoggingConfig]]
    '(Amazon MSK, and self-managed Apache Kafka only) The logging configuration for your event source.'
    Queues: NotRequired[Expr[list[Expr[str]]]]
    '(Amazon MQ) The name of the Amazon MQ broker destination queue to consume.'
    FunctionResponseTypes: NotRequired[Expr[list[Expr[str]]]]
    '(Kinesis, DynamoDB Streams, and SQS) A list of current response type enums applied to the event source mapping.'


class EventSourceMapping(ResourceAttrs):
    'The ``AWS::Lambda::EventSourceMapping`` resource creates a mapping between an event source and an LAMlong function.'
    Type: Literal['AWS::Lambda::EventSourceMapping']
    Properties: EventSourceMappingProps


def event_source_mapping(
    *,
    depends_on: DependsOn | None = None,
    deletion_policy: DeletionPolicy | None = None,
    update_replace_policy: UpdateReplacePolicy | None = None,
    condition: str | None = None,
    metadata: dict[str, Any] | None = None,
    **props: Unpack[EventSourceMappingProps],
) -> EventSourceMapping:
    return build('AWS::Lambda::EventSourceMapping', props, depends_on, deletion_policy, update_replace_policy, condition, metadata)

Attributes

Read-only values for get_att(logical_id, attribute). They are not accepted as inputs.

  • EventSourceMappingArn
  • Id