Class ManagedKafkaEventSourceProps
Properties for a MSK event source.
Inheritance
Namespace: Amazon.CDK.AWS.Lambda.EventSources
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class ManagedKafkaEventSourceProps : Object, IManagedKafkaEventSourceProps, IKafkaEventSourceProps, IBaseStreamEventSourceProps
Syntax (vb)
Public Class ManagedKafkaEventSourceProps
Inherits Object
Implements IManagedKafkaEventSourceProps, IKafkaEventSourceProps, IBaseStreamEventSourceProps
Remarks
ExampleMetadata: infused
Examples
using Amazon.CDK.AWS.SecretsManager;
using Amazon.CDK.AWS.Lambda.EventSources;
Function myFunction;
// Your MSK cluster arn
var clusterArn = "arn:aws:kafka:us-east-1:0123456789019:cluster/SalesCluster/abcd1234-abcd-cafe-abab-9876543210ab-4";
// The Kafka topic you want to subscribe to
var topic = "some-cool-topic";
// The secret that allows access to your MSK cluster
// You still have to make sure that it is associated with your cluster as described in the documentation
var secret = new Secret(this, "Secret", new SecretProps { SecretName = "AmazonMSK_KafkaSecret" });
myFunction.AddEventSource(new ManagedKafkaEventSource(new ManagedKafkaEventSourceProps {
ClusterArn = clusterArn,
Topic = topic,
Secret = secret,
BatchSize = 100, // default
StartingPosition = StartingPosition.TRIM_HORIZON
}));
Synopsis
Constructors
ManagedKafkaEventSourceProps() |
Properties
BatchSize | The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function. |
ClusterArn | An MSK cluster construct. |
ConsumerGroupId | The identifier for the Kafka consumer group to join. |
Enabled | If the stream event source mapping should be enabled. |
Filters | Add filter criteria to Event Source. |
MaxBatchingWindow | The maximum amount of time to gather records before invoking the function. |
OnFailure | Add an on Failure Destination for this Kafka event. |
Secret | The secret with the Kafka credentials, see https://docs.aws.amazon.com/msk/latest/developerguide/msk-password.html for details This field is required if your Kafka brokers are accessed over the Internet. |
StartingPosition | Where to begin consuming the stream. |
Topic | The Kafka topic to subscribe to. |
Constructors
ManagedKafkaEventSourceProps()
public ManagedKafkaEventSourceProps()
Properties
BatchSize
The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.
public Nullable<double> BatchSize { get; set; }
Property Value
System.Nullable<System.Double>
Remarks
Your function receives an event with all the retrieved records.
Valid Range:
Default: 100
ClusterArn
An MSK cluster construct.
public string ClusterArn { get; set; }
Property Value
System.String
ConsumerGroupId
The identifier for the Kafka consumer group to join.
public string ConsumerGroupId { get; set; }
Property Value
System.String
Remarks
The consumer group ID must be unique among all your Kafka event sources. After creating a Kafka event source mapping with the consumer group ID specified, you cannot update this value. The value must have a lenght between 1 and 200 and full the pattern '[a-zA-Z0-9-/:_+=.@-]'.
Default: - none
See: https://docs.aws.amazon.com/lambda/latest/dg/with-msk.html#services-msk-consumer-group-id
Enabled
If the stream event source mapping should be enabled.
public Nullable<bool> Enabled { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: true
Filters
Add filter criteria to Event Source.
public IDictionary<string, object>[] Filters { get; set; }
Property Value
System.Collections.Generic.IDictionary<System.String, System.Object>[]
Remarks
Default: - none
See: https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html
MaxBatchingWindow
The maximum amount of time to gather records before invoking the function.
public Duration MaxBatchingWindow { get; set; }
Property Value
Remarks
Maximum of Duration.minutes(5).
Default: - Duration.seconds(0) for Kinesis, DynamoDB, and SQS event sources, Duration.millis(500) for MSK, self-managed Kafka, and Amazon MQ.
OnFailure
Add an on Failure Destination for this Kafka event.
public IEventSourceDlq OnFailure { get; set; }
Property Value
Remarks
SNS/SQS/S3 are supported
Default: - discarded records are ignored
Secret
The secret with the Kafka credentials, see https://docs.aws.amazon.com/msk/latest/developerguide/msk-password.html for details This field is required if your Kafka brokers are accessed over the Internet.
public ISecret Secret { get; set; }
Property Value
Remarks
Default: none
StartingPosition
Where to begin consuming the stream.
public StartingPosition StartingPosition { get; set; }
Property Value
Topic
The Kafka topic to subscribe to.
public string Topic { get; set; }
Property Value
System.String