-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(lambda-event-sources): Support MSK and self hosted Kafka #12099
Comments
It could look like this: export type KafkaEventSourceProps = StreamEventSourceProps
class KafkaEventSource extends StreamEventSource {
constructor(readonly clusterArn: string,
readonly kafkaTopic: string,
readonly secretArn: string,
readonly kmsKeyArn: string,
props: KafkaEventSourceProps) {
super(props);
}
public bind(target: lambda.IFunction) {
const eventSourceMapping = target.addEventSourceMapping(
`KafkaEventSource:${this.kafkaTopic}`,
this.enrichMappingOptions({
eventSourceArn: this.clusterArn,
kafkaTopic: this.kafkaTopic,
startingPosition: this.props.startingPosition
})
);
target.addToRolePolicy(new iam.PolicyStatement(
{
actions: ['secretsmanager:GetSecretValue'],
resources: [this.secretArn],
})
);
target.addToRolePolicy(new iam.PolicyStatement(
{
actions: ['kms:Decrypt'],
resources: [this.kmsKeyArn],
})
);
target.addToRolePolicy(new iam.PolicyStatement(
{
actions: ['kafka:DescribeCluster', 'kafka:GetBootstrapBrokers', 'kafka:ListScramSecrets'],
resources: [this.clusterArn]
}
));
target.role?.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSLambdaMSKExecutionRole'));
const cfnEventSourceMapping = eventSourceMapping.node.defaultChild as lambda.CfnEventSourceMapping;
cfnEventSourceMapping.sourceAccessConfigurations = [{type: 'SASL_SCRAM_512_AUTH', uri: this.secretArn}];
}
} |
For a self hosted Kafka cluster this is needed as well: aws-cloudformation/cloudformation-coverage-roadmap#723 Or it could be retrofitted with Maybe we have a quick chat @nija-at? |
If it's supported by the AWS SDK for Javascript, you could absolutely use a custom resource until support for it is available via CloudFormation. @bracki - I'm out on vacation for the next 2 weeks but feel free to take a stab at a PR here. You can DM me (once I'm back) on the public CDK Slack channel (details at https://cdk.dev/) |
|
Add a
KafkaEventSource
that implementsStreamEventSource
and allows configuring either MSK or a self hosted Kafka cluster as described here and here.Use Case
I want to setup MSK/Kafka as event source for Lambda without doing it with the lower level
CfnEventSourceMapping
.Proposed Solution
Add a class
KafkaEventSource
that implementsStreamEventSource
.This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: