Skip to content
v2.273.0

EventRecordFormat Class ​

The format target function should receive record in.

Example ​

ts
import { ManagedKafkaEventSource, ConfluentSchemaRegistry } from 'aws-cdk-lib/aws-lambda-event-sources';
import { Secret } from 'aws-cdk-lib/aws-secretsmanager';

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

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

const secret = new Secret(this, 'Secret', { secretName: 'AmazonMSK_KafkaSecret' });

declare const myFunction: lambda.Function;
myFunction.addEventSource(new ManagedKafkaEventSource({
  clusterArn,
  topic,
  startingPosition: lambda.StartingPosition.TRIM_HORIZON,
  provisionedPollerConfig: {
    minimumPollers: 1,
    maximumPollers: 3,
  },
  schemaRegistryConfig: new ConfluentSchemaRegistry({
    schemaRegistryUri: 'https://example.com',
    eventRecordFormat: lambda.EventRecordFormat.JSON,
    authenticationType: lambda.KafkaSchemaRegistryAccessConfigType.BASIC_AUTH,
    secret: secret,
    schemaValidationConfigs: [{ attribute: lambda.KafkaSchemaValidationAttribute.KEY }],
  }),
}));

Properties ​

The target function will receive records as json objects.
The target function will receive records in same format as the schema source.
valuestringvaluestrvalueStringValuestringValue*stringrequired#
The enum to use in `SchemaRegistryConfig.EventRecordFormat` property in CloudFormation.

Methods ​

of(name: string): EventRecordFormat // chainable@staticmethod def of(name: str) -> EventRecordFormatpublic static EventRecordFormat of(String name)public static EventRecordFormat Of(string name)func Of(Name *string) EventRecordFormatstatic#
A custom event record format.