# GlueSchemaRegistry

Glue schema registry configuration for a Lambda event source.

Implements: [ISchemaRegistry](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.ISchemaRegistry.html)

- Source: [`aws-lambda-event-sources/lib/glue-schema-registry.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-lambda-event-sources/lib/glue-schema-registry.ts#L31)
- Type last changed: v2.202.0 · 20 Jun 2025

## Example

TypeScript:

```ts
import { CfnRegistry } from 'aws-cdk-lib/aws-glue';
import { ManagedKafkaEventSource, GlueSchemaRegistry } from 'aws-cdk-lib/aws-lambda-event-sources';

// Your MSK cluster arn
declare const clusterArn: string;

// The Kafka topic you want to subscribe to
const topic = 'some-cool-topic';

// Your Glue Schema Registry
const glueRegistry = new CfnRegistry(this, 'Registry', {
  name: 'schema-registry',
  description: 'Schema registry for event source',
});

declare const myFunction: lambda.Function;
myFunction.addEventSource(new ManagedKafkaEventSource({
  clusterArn,
  topic,
  startingPosition: lambda.StartingPosition.TRIM_HORIZON,
  provisionedPollerConfig: {
    minimumPollers: 1,
    maximumPollers: 3,
  },
  schemaRegistryConfig: new GlueSchemaRegistry({
    schemaRegistry: glueRegistry,
    eventRecordFormat: lambda.EventRecordFormat.JSON,
    schemaValidationConfigs: [{ attribute: lambda.KafkaSchemaValidationAttribute.KEY }],
  }),
}));
```

Python:

```python
from aws_cdk.aws_lambda_event_sources import ProvisionedPollerConfig
from aws_cdk.aws_glue import CfnRegistry
from aws_cdk.aws_lambda_event_sources import ManagedKafkaEventSource, GlueSchemaRegistry

# Your MSK cluster arn
# cluster_arn: str

# my_function: lambda.Function

# The Kafka topic you want to subscribe to
topic = "some-cool-topic"

# Your Glue Schema Registry
glue_registry = CfnRegistry(self, "Registry",
    name="schema-registry",
    description="Schema registry for event source"
)
my_function.add_event_source(ManagedKafkaEventSource(
    cluster_arn=cluster_arn,
    topic=topic,
    starting_position=lambda_.StartingPosition.TRIM_HORIZON,
    provisioned_poller_config=ProvisionedPollerConfig(
        minimum_pollers=1,
        maximum_pollers=3
    ),
    schema_registry_config=GlueSchemaRegistry(
        schema_registry=glue_registry,
        event_record_format=lambda_.EventRecordFormat.JSON,
        schema_validation_configs=[lambda.KafkaSchemaValidationConfig(attribute=lambda_.KafkaSchemaValidationAttribute.KEY)]
    )
))
```

Java:

```java
import software.amazon.awscdk.services.glue.CfnRegistry;
import software.amazon.awscdk.services.lambda.eventsources.ManagedKafkaEventSource;
import software.amazon.awscdk.services.lambda.eventsources.GlueSchemaRegistry;

// Your MSK cluster arn
String clusterArn;

Function myFunction;

// The Kafka topic you want to subscribe to
String topic = "some-cool-topic";

// Your Glue Schema Registry
CfnRegistry glueRegistry = CfnRegistry.Builder.create(this, "Registry")
        .name("schema-registry")
        .description("Schema registry for event source")
        .build();
myFunction.addEventSource(ManagedKafkaEventSource.Builder.create()
        .clusterArn(clusterArn)
        .topic(topic)
        .startingPosition(StartingPosition.TRIM_HORIZON)
        .provisionedPollerConfig(ProvisionedPollerConfig.builder()
                .minimumPollers(1)
                .maximumPollers(3)
                .build())
        .schemaRegistryConfig(GlueSchemaRegistry.Builder.create()
                .schemaRegistry(glueRegistry)
                .eventRecordFormat(EventRecordFormat.JSON)
                .schemaValidationConfigs(List.of(KafkaSchemaValidationConfig.builder().attribute(KafkaSchemaValidationAttribute.KEY).build()))
                .build())
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Glue;
using Amazon.CDK.AWS.Lambda.EventSources;

// Your MSK cluster arn
string clusterArn;

Function myFunction;

// The Kafka topic you want to subscribe to
var topic = "some-cool-topic";

// Your Glue Schema Registry
var glueRegistry = new CfnRegistry(this, "Registry", new CfnRegistryProps {
    Name = "schema-registry",
    Description = "Schema registry for event source"
});
myFunction.AddEventSource(new ManagedKafkaEventSource(new ManagedKafkaEventSourceProps {
    ClusterArn = clusterArn,
    Topic = topic,
    StartingPosition = StartingPosition.TRIM_HORIZON,
    ProvisionedPollerConfig = new ProvisionedPollerConfig {
        MinimumPollers = 1,
        MaximumPollers = 3
    },
    SchemaRegistryConfig = new GlueSchemaRegistry(new GlueSchemaRegistryProps {
        SchemaRegistry = glueRegistry,
        EventRecordFormat = EventRecordFormat.JSON,
        SchemaValidationConfigs = new [] { new KafkaSchemaValidationConfig { Attribute = KafkaSchemaValidationAttribute.KEY } }
    })
}));
```

Golang:

```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"

// Your MSK cluster arn
var clusterArn string

var myFunction Function

// The Kafka topic you want to subscribe to
topic := "some-cool-topic"

// Your Glue Schema Registry
glueRegistry := awscdk.NewCfnRegistry(this, jsii.String("Registry"), &CfnRegistryProps{
	Name: jsii.String("schema-registry"),
	Description: jsii.String("Schema registry for event source"),
})
myFunction.AddEventSource(awscdk.NewManagedKafkaEventSource(&ManagedKafkaEventSourceProps{
	ClusterArn: jsii.String(ClusterArn),
	Topic: jsii.String(Topic),
	StartingPosition: lambda.StartingPosition_TRIM_HORIZON,
	ProvisionedPollerConfig: &ProvisionedPollerConfig{
		MinimumPollers: jsii.Number(1),
		MaximumPollers: jsii.Number(3),
	},
	SchemaRegistryConfig: awscdk.NewGlueSchemaRegistry(&GlueSchemaRegistryProps{
		SchemaRegistry: glueRegistry,
		EventRecordFormat: lambda.EventRecordFormat_JSON(),
		SchemaValidationConfigs: []KafkaSchemaValidationConfig{
			&KafkaSchemaValidationConfig{
				Attribute: lambda.KafkaSchemaValidationAttribute_KEY(),
			},
		},
	}),
}))
```

## Initializer

TypeScript:

```ts
new GlueSchemaRegistry(props: GlueSchemaRegistryProps)
```

Python:

```python
GlueSchemaRegistry(props: GlueSchemaRegistryProps)
```

Java:

```java
new GlueSchemaRegistry(GlueSchemaRegistryProps props)
```

C# / .NET:

```csharp
new GlueSchemaRegistry(GlueSchemaRegistryProps props)
```

Golang:

```go
NewGlueSchemaRegistry(Props GlueSchemaRegistryProps)
```

## Methods

- `bind(_target: IEventSourceMapping, targetHandler: IFunction): KafkaSchemaRegistryConfig` — Returns a schema registry configuration.
