Class ManagedKafkaEventSourceProps
Properties for a MSK event source.
Inheritance
Namespace: Amazon.CDK.AWS.Lambda.EventSources
Assembly: Amazon.CDK.AWS.Lambda.EventSources.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. |
Enabled | If the stream event source mapping should be enabled. |
MaxBatchingWindow | The maximum amount of time to gather records before invoking the function. |
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
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
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)
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