@Generated(value="jsii-pacmak/1.73.0 (build 6faeda3)", date="2023-01-31T18:36:54.521Z") public class EventSourceMapping extends Resource implements IEventSourceMapping
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 { SqsEventSource } from '@aws-cdk/aws-lambda-event-sources'; lambda.addEventSource(new SqsEventSource(sqs));
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.services.lambda.*; import software.amazon.awscdk.core.*; IEventSourceDlq eventSourceDlq; Function function_; SourceAccessConfigurationType sourceAccessConfigurationType; EventSourceMapping eventSourceMapping = EventSourceMapping.Builder.create(this, "MyEventSourceMapping") .target(function_) // the properties below are optional .batchSize(123) .bisectBatchOnError(false) .enabled(false) .eventSourceArn("eventSourceArn") .kafkaBootstrapServers(List.of("kafkaBootstrapServers")) .kafkaTopic("kafkaTopic") .maxBatchingWindow(Duration.minutes(30)) .maxRecordAge(Duration.minutes(30)) .onFailure(eventSourceDlq) .parallelizationFactor(123) .reportBatchItemFailures(false) .retryAttempts(123) .sourceAccessConfigurations(List.of(SourceAccessConfiguration.builder() .type(sourceAccessConfigurationType) .uri("uri") .build())) .startingPosition(StartingPosition.TRIM_HORIZON) .tumblingWindow(Duration.minutes(30)) .build();
Modifier and Type | Class and Description |
---|---|
static class |
EventSourceMapping.Builder
A fluent builder for
EventSourceMapping . |
IEventSourceMapping.Jsii$Default, IEventSourceMapping.Jsii$Proxy
Modifier | Constructor and Description |
---|---|
protected |
EventSourceMapping(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
EventSourceMapping(software.amazon.jsii.JsiiObjectRef objRef) |
|
EventSourceMapping(software.constructs.Construct scope,
java.lang.String id,
EventSourceMappingProps props) |
Modifier and Type | Method and Description |
---|---|
static IEventSourceMapping |
fromEventSourceMappingId(software.constructs.Construct scope,
java.lang.String id,
java.lang.String eventSourceMappingId)
Import an event source into this stack from its event source id.
|
java.lang.String |
getEventSourceMappingId()
The identifier for this EventSourceMapping.
|
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResource
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applyRemovalPolicy, getEnv, getStack
getNode
protected EventSourceMapping(software.amazon.jsii.JsiiObjectRef objRef)
protected EventSourceMapping(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public EventSourceMapping(software.constructs.Construct scope, java.lang.String id, EventSourceMappingProps props)
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.public static IEventSourceMapping fromEventSourceMappingId(software.constructs.Construct scope, java.lang.String id, java.lang.String eventSourceMappingId)
scope
- This parameter is required.id
- This parameter is required.eventSourceMappingId
- This parameter is required.public java.lang.String getEventSourceMappingId()
getEventSourceMappingId
in interface IEventSourceMapping