Skip to content
v2.277.0

AuthenticationMethod Enum ​

The authentication method to use with SelfManagedKafkaEventSource.

Example ​

ts
import { SelfManagedKafkaEventSource, AuthenticationMethod } from 'aws-cdk-lib/aws-lambda-event-sources';
import { StartingPosition, Function } from 'aws-cdk-lib/aws-lambda';
import { ISecret } from 'aws-cdk-lib/aws-secretsmanager';

// With provisioned pollers and poller group for cost optimization
declare const myFunction: Function;
declare const kafkaCredentials: ISecret;
myFunction.addEventSource(new SelfManagedKafkaEventSource({
  bootstrapServers: ['kafka-broker1.example.com:9092', 'kafka-broker2.example.com:9092'],
  topic: 'events-topic',
  secret: kafkaCredentials,
  startingPosition: StartingPosition.LATEST,
  authenticationMethod: AuthenticationMethod.SASL_SCRAM_512_AUTH,
  provisionedPollerConfig: {
    minimumPollers: 1,
    maximumPollers: 8,
    pollerGroupName: 'self-managed-kafka-group', // Group pollers to reduce costs
  },
}));
python
from aws_cdk.aws_lambda_event_sources import ProvisionedPollerConfig
from aws_cdk.aws_lambda_event_sources import SelfManagedKafkaEventSource, AuthenticationMethod
from aws_cdk.aws_lambda import StartingPosition, Function
from aws_cdk.aws_secretsmanager import ISecret

# With provisioned pollers and poller group for cost optimization
# my_function: Function
# kafka_credentials: ISecret

my_function.add_event_source(SelfManagedKafkaEventSource(
    bootstrap_servers=["kafka-broker1.example.com:9092", "kafka-broker2.example.com:9092"],
    topic="events-topic",
    secret=kafka_credentials,
    starting_position=StartingPosition.LATEST,
    authentication_method=AuthenticationMethod.SASL_SCRAM_512_AUTH,
    provisioned_poller_config=ProvisionedPollerConfig(
        minimum_pollers=1,
        maximum_pollers=8,
        poller_group_name="self-managed-kafka-group"
    )
))
java
import software.amazon.awscdk.services.lambda.eventsources.SelfManagedKafkaEventSource;
import software.amazon.awscdk.services.lambda.eventsources.AuthenticationMethod;
import software.amazon.awscdk.services.lambda.StartingPosition;
import software.amazon.awscdk.services.lambda.Function;
import software.amazon.awscdk.services.secretsmanager.ISecret;

// With provisioned pollers and poller group for cost optimization
Function myFunction;
ISecret kafkaCredentials;

myFunction.addEventSource(SelfManagedKafkaEventSource.Builder.create()
        .bootstrapServers(List.of("kafka-broker1.example.com:9092", "kafka-broker2.example.com:9092"))
        .topic("events-topic")
        .secret(kafkaCredentials)
        .startingPosition(StartingPosition.LATEST)
        .authenticationMethod(AuthenticationMethod.SASL_SCRAM_512_AUTH)
        .provisionedPollerConfig(ProvisionedPollerConfig.builder()
                .minimumPollers(1)
                .maximumPollers(8)
                .pollerGroupName("self-managed-kafka-group")
                .build())
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Lambda.EventSources;
using Amazon.CDK.AWS.Lambda;
using Amazon.CDK.AWS.SecretsManager;

// With provisioned pollers and poller group for cost optimization
Function myFunction;
ISecret kafkaCredentials;

myFunction.AddEventSource(new SelfManagedKafkaEventSource(new SelfManagedKafkaEventSourceProps {
    BootstrapServers = new [] { "kafka-broker1.example.com:9092", "kafka-broker2.example.com:9092" },
    Topic = "events-topic",
    Secret = kafkaCredentials,
    StartingPosition = StartingPosition.LATEST,
    AuthenticationMethod = AuthenticationMethod.SASL_SCRAM_512_AUTH,
    ProvisionedPollerConfig = new ProvisionedPollerConfig {
        MinimumPollers = 1,
        MaximumPollers = 8,
        PollerGroupName = "self-managed-kafka-group"
    }
}));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

// With provisioned pollers and poller group for cost optimization
var myFunction Function
var kafkaCredentials ISecret

myFunction.AddEventSource(awscdk.NewSelfManagedKafkaEventSource(&SelfManagedKafkaEventSourceProps{
	BootstrapServers: []*string{
		jsii.String("kafka-broker1.example.com:9092"),
		jsii.String("kafka-broker2.example.com:9092"),
	},
	Topic: jsii.String("events-topic"),
	Secret: kafkaCredentials,
	StartingPosition: awscdk.StartingPosition_LATEST,
	AuthenticationMethod: awscdk.AuthenticationMethod_SASL_SCRAM_512_AUTH,
	ProvisionedPollerConfig: &ProvisionedPollerConfig{
		MinimumPollers: jsii.Number(1),
		MaximumPollers: jsii.Number(8),
		PollerGroupName: jsii.String("self-managed-kafka-group"),
	},
}))

Members ​

MemberDescription
SASL_SCRAM_512_AUTHSASL_SCRAM_512_AUTH authentication method for your Kafka cluster.
SASL_SCRAM_256_AUTHSASL_SCRAM_256_AUTH authentication method for your Kafka cluster.
BASIC_AUTHBASIC_AUTH (SASL/PLAIN) authentication method for your Kafka cluster.
CLIENT_CERTIFICATE_TLS_AUTHCLIENT_CERTIFICATE_TLS_AUTH (mTLS) authentication method for your Kafka cluster.

Referenced by ​