Class ManagedKafkaEventSourceProps
Properties for a MSK event source.
Inherited Members
Namespace: Amazon.CDK.AWS.Lambda.EventSources
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class ManagedKafkaEventSourceProps : IManagedKafkaEventSourceProps, IKafkaEventSourceProps, IBaseStreamEventSourceProps
Syntax (vb)
Public Class ManagedKafkaEventSourceProps Implements IManagedKafkaEventSourceProps, IKafkaEventSourceProps, IBaseStreamEventSourceProps
Remarks
ExampleMetadata: infused
Examples
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";
// Enable basic event and error metrics
myFunction.AddEventSource(new ManagedKafkaEventSource(new ManagedKafkaEventSourceProps {
ClusterArn = clusterArn,
Topic = "basic-monitoring",
StartingPosition = StartingPosition.LATEST,
// Provisioned mode is required for observability features
ProvisionedPollerConfig = new ProvisionedPollerConfig {
MinimumPollers = 2,
MaximumPollers = 10
},
MetricsConfig = new MetricsConfig {
Metrics = new [] { MetricType.EVENT_COUNT, MetricType.ERROR_COUNT }
}
}));
Synopsis
Constructors
| ManagedKafkaEventSourceProps() | Properties for a MSK event source. |
Properties
| BatchSize | The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function. |
| BisectBatchOnError | |
| 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. |
| FilterEncryption | Add Customer managed KMS key to encrypt Filter Criteria. |
| Filters | Add filter criteria to Event Source. |
| LogLevel | Configuration for logging verbosity from the event source mapping poller. |
| MaxBatchingWindow | The maximum amount of time to gather records before invoking the function. |
| MaxRecordAge | The maximum age of a record that Lambda sends to a function for processing. |
| MetricsConfig | Configuration for enhanced monitoring metrics collection. |
| OnFailure | Add an on Failure Destination for this Kafka event. |
| ProvisionedPollerConfig | Configuration for provisioned pollers that read from the event source. |
| ReportBatchItemFailures | |
| RetryAttempts | |
| SchemaRegistryConfig | Specific configuration settings for a Kafka schema registry. |
| 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. |
| StartingPositionTimestamp | The time from which to start reading, in Unix time seconds. |
| Topic | The Kafka topic to subscribe to. |
Constructors
ManagedKafkaEventSourceProps()
Properties for a MSK event source.
public ManagedKafkaEventSourceProps()
Remarks
ExampleMetadata: infused
Examples
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";
// Enable basic event and error metrics
myFunction.AddEventSource(new ManagedKafkaEventSource(new ManagedKafkaEventSourceProps {
ClusterArn = clusterArn,
Topic = "basic-monitoring",
StartingPosition = StartingPosition.LATEST,
// Provisioned mode is required for observability features
ProvisionedPollerConfig = new ProvisionedPollerConfig {
MinimumPollers = 2,
MaximumPollers = 10
},
MetricsConfig = new MetricsConfig {
Metrics = new [] { MetricType.EVENT_COUNT, MetricType.ERROR_COUNT }
}
}));
Properties
BatchSize
The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.
public double? BatchSize { get; set; }
Property Value
Remarks
Your function receives an event with all the retrieved records.
Valid Range:
Default: 100
BisectBatchOnError
- If the function returns an error, split the batch in two and retry.
public bool? BisectBatchOnError { get; set; }
Property Value
bool?
Remarks
Default: false
ClusterArn
An MSK cluster construct.
public string ClusterArn { get; set; }
Property Value
Remarks
ExampleMetadata: infused
ConsumerGroupId
The identifier for the Kafka consumer group to join.
public string? ConsumerGroupId { get; set; }
Property Value
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 length 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 bool? Enabled { get; set; }
Property Value
bool?
Remarks
Default: true
FilterEncryption
Add Customer managed KMS key to encrypt Filter Criteria.
public IKey? FilterEncryption { get; set; }
Property Value
Remarks
Default: - none
See: https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-managed-cmk
Filters
Add filter criteria to Event Source.
public IDictionary<string, object>[]? Filters { get; set; }
Property Value
IDictionary<string, object>[]
Remarks
Default: - none
See: https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html
LogLevel
Configuration for logging verbosity from the event source mapping poller.
public EventSourceMappingLogLevel? LogLevel { get; set; }
Property Value
Remarks
Default: - No logging
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.
MaxRecordAge
The maximum age of a record that Lambda sends to a function for processing.
public Duration? MaxRecordAge { get; set; }
Property Value
Remarks
The default value is -1, which sets the maximum age to infinite. When the value is set to infinite, Lambda never discards old records. Record are valid until it expires in the event source.
Default: -1
MetricsConfig
Configuration for enhanced monitoring metrics collection.
public IMetricsConfig? MetricsConfig { get; set; }
Property Value
Remarks
Default: - Enhanced monitoring is disabled
OnFailure
Add an on Failure Destination for this Kafka event.
public IEventSourceDlq? OnFailure { get; set; }
Property Value
Remarks
Supported destinations:
Default: - discarded records are ignored
ProvisionedPollerConfig
Configuration for provisioned pollers that read from the event source.
public IProvisionedPollerConfig? ProvisionedPollerConfig { get; set; }
Property Value
Remarks
When specified, allows control over the minimum and maximum number of pollers that can be provisioned to process events from the source.
Default: - no provisioned pollers
See: https://docs.aws.amazon.com/lambda/latest/dg/kafka-scaling-modes.html
ReportBatchItemFailures
- Allow functions to return partially successful responses for a batch of records.
public bool? ReportBatchItemFailures { get; set; }
Property Value
bool?
Remarks
Default: false
RetryAttempts
- Maximum number of retry attempts.
public double? RetryAttempts { get; set; }
Property Value
Remarks
Set to -1 for infinite retries (until the record expires in the event source).
Default: -1 (infinite retries)
SchemaRegistryConfig
Specific configuration settings for a Kafka schema registry.
public ISchemaRegistry? SchemaRegistryConfig { get; set; }
Property Value
Remarks
Default: - none
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
Remarks
ExampleMetadata: infused
StartingPositionTimestamp
The time from which to start reading, in Unix time seconds.
public double? StartingPositionTimestamp { get; set; }
Property Value
Remarks
Default: - no timestamp
Topic
The Kafka topic to subscribe to.
public string Topic { get; set; }
Property Value
Remarks
ExampleMetadata: infused