Class EventSourceMapping
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.lambda.EventSourceMapping
- All Implemented Interfaces:
IResource
,IEventSourceMapping
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
@Generated(value="jsii-pacmak/1.104.0 (build e79254c)",
date="2024-12-17T21:37:33.404Z")
@Stability(Stable)
public class EventSourceMapping
extends Resource
implements IEventSourceMapping
Defines a Lambda EventSourceMapping resource.
Usually, you won't need to define the mapping yourself. This will usually be done by event sources. For example, to add an SQS event source to a function:
import software.amazon.awscdk.services.sqs.*; import software.amazon.awscdk.services.lambda.eventsources.*; Function handler; Queue queue; handler.addEventSource(new SqsEventSource(queue));
The SqsEventSource
class will automatically create the mapping, and will also
modify the Lambda's execution role so it can consume messages from the queue.
Example:
// The code below shows an example of how to instantiate this type. // The values are placeholders you should change. import software.amazon.awscdk.*; import software.amazon.awscdk.services.kms.*; import software.amazon.awscdk.services.lambda.*; IEventSourceDlq eventSourceDlq; Object filters; Function function_; Key key; SourceAccessConfigurationType sourceAccessConfigurationType; EventSourceMapping eventSourceMapping = EventSourceMapping.Builder.create(this, "MyEventSourceMapping") .target(function_) // the properties below are optional .batchSize(123) .bisectBatchOnError(false) .enabled(false) .eventSourceArn("eventSourceArn") .filterEncryption(key) .filters(List.of(Map.of( "filtersKey", filters))) .kafkaBootstrapServers(List.of("kafkaBootstrapServers")) .kafkaConsumerGroupId("kafkaConsumerGroupId") .kafkaTopic("kafkaTopic") .maxBatchingWindow(Duration.minutes(30)) .maxConcurrency(123) .maxRecordAge(Duration.minutes(30)) .metricsConfig(MetricsConfig.builder() .metrics(List.of(MetricType.EVENT_COUNT)) .build()) .onFailure(eventSourceDlq) .parallelizationFactor(123) .provisionedPollerConfig(ProvisionedPollerConfig.builder() .maximumPollers(123) .minimumPollers(123) .build()) .reportBatchItemFailures(false) .retryAttempts(123) .sourceAccessConfigurations(List.of(SourceAccessConfiguration.builder() .type(sourceAccessConfigurationType) .uri("uri") .build())) .startingPosition(StartingPosition.TRIM_HORIZON) .startingPositionTimestamp(123) .supportS3OnFailureDestination(false) .tumblingWindow(Duration.minutes(30)) .build();
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.lambda.IEventSourceMapping
IEventSourceMapping.Jsii$Default, IEventSourceMapping.Jsii$Proxy
Nested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default
-
Constructor Summary
ModifierConstructorDescriptionprotected
EventSourceMapping
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
EventSourceMapping
(software.amazon.jsii.JsiiObjectRef objRef) EventSourceMapping
(software.constructs.Construct scope, String id, EventSourceMappingProps props) -
Method Summary
Modifier and TypeMethodDescriptionstatic IEventSourceMapping
fromEventSourceMappingId
(software.constructs.Construct scope, String id, String eventSourceMappingId) Import an event source into this stack from its event source id.The ARN of the event source mapping (i.e.The identifier for this EventSourceMapping.Methods inherited from class software.amazon.awscdk.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResource
Methods inherited from class software.constructs.Construct
getNode, isConstruct, toString
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.constructs.IConstruct
getNode
Methods inherited from interface software.amazon.awscdk.IResource
applyRemovalPolicy, getEnv, getStack
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
EventSourceMapping
protected EventSourceMapping(software.amazon.jsii.JsiiObjectRef objRef) -
EventSourceMapping
protected EventSourceMapping(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
EventSourceMapping
@Stability(Stable) public EventSourceMapping(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull EventSourceMappingProps props) - Parameters:
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.
-
-
Method Details
-
fromEventSourceMappingId
@Stability(Stable) @NotNull public static IEventSourceMapping fromEventSourceMappingId(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String eventSourceMappingId) Import an event source into this stack from its event source id.- Parameters:
scope
- This parameter is required.id
- This parameter is required.eventSourceMappingId
- This parameter is required.
-
getEventSourceMappingArn
The ARN of the event source mapping (i.e. arn:aws:lambda:region:account-id:event-source-mapping/event-source-mapping-id).- Specified by:
getEventSourceMappingArn
in interfaceIEventSourceMapping
-
getEventSourceMappingId
The identifier for this EventSourceMapping.- Specified by:
getEventSourceMappingId
in interfaceIEventSourceMapping
-