You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(lambda): support for schema registry for kafka (#34746)
### Reason for this change
Lambda is introducing a new property in Event Sources named `SchemaRegistryConfig` in `SelfManagedKafkaEventSourceConfig` and `AmazonManagedKafkaEventSourceConfig` to set configuration settings for a schema registry that will be used to de-serialize the event read from these Kafka event sources. When specified, it allows de-serialization events before they are passed to target function and validation of their format. The users may use a Confluent registry, a self managed registry or AWS Glue Registry. Note, the even source mapping must have `ProvisionedPollerConfig` set (be on provisioned mode) for this feature to be used.
This feature is currently supported for MSK and Self-managed Kafka event sources.
### Description of changes
This new property can be opted in by setting `SchemaRegistryConfig` in `SelfManagedKafkaEventSourceConfig` or `AmazonManagedKafkaEventSourceConfig`. An example is shown bellow:
```
myFunction.addEventSource(new ManagedKafkaEventSource({
clusterArn,
topic,
startingPosition: lambda.StartingPosition.TRIM_HORIZON,
provisionedPollerConfig: {
minimumPollers: 1,
maximumPollers: 3,
},
schemaRegistryConfig: {
schemaRegistryUri: 'https://example.com',
eventRecordFormat: lambda.EventRecordFormat.JSON,
accessConfigs: [
{
type: lambda.SchemaRegistryAccessConfigType.BASIC_AUTH,
uri: 'https://example.com',
},
],
schemaValidationConfigs: [{ attribute: lambda.SchemaValidationAttribute.KEY }],
},
}));
```
### Describe any new or updated permissions being added
Following IAM permissions will be added to the target function execution role **only if user passed a Glue registry**.
```
{
Action: 'glue:GetRegistry',
Effect: 'Allow',
Resource: {
'Fn::GetAtt': ['Registry', 'Arn'], // Glue registry ARN
},
},
{
Action: [
'glue:GetSchemaVersion',
'glue:GetSchema',
],
Effect: 'Allow',
Resource: [
{
'Fn::GetAtt': ['Registry', 'Arn'],
},
'arn:${AWS::Partition}:glue:${AWS::Region}:${AWS::AccountId}:schema/lambda-gp-test-glue-schema-registry/*',
],
},
```
### Description of how you validated changes
Unit tests for each case have been added in the PR. Note, MSK and SMK validations follow the same path so for validations there are only unit tests for MSK cases which should apply for both.
Integration test for both Glue and confluent case have been added for SMK. Since, MSK requires a Kafka cluster in VPC that we typically do not add integration tests for it.
### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy file name to clipboardExpand all lines: packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kafka-schema-registry.js.snapshot/SchemaRegistryIntegDefaultTestDeployAssertC190A9FD.assets.json
Copy file name to clipboardExpand all lines: packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kafka-schema-registry.js.snapshot/SchemaRegistryIntegDefaultTestDeployAssertC190A9FD.template.json
Copy file name to clipboardExpand all lines: packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kafka-schema-registry.js.snapshot/cdk.out
Copy file name to clipboardExpand all lines: packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kafka-schema-registry.js.snapshot/integ.json
Copy file name to clipboardExpand all lines: packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kafka-schema-registry.js.snapshot/lambda-event-source-confluent-schema-registry.assets.json
Copy file name to clipboardExpand all lines: packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kafka-schema-registry.js.snapshot/lambda-event-source-glue-schema-registry.assets.json
0 commit comments