97+ pre-built Zod schemas for AWS Lambda event sources. All schemas provide TypeScript type inference and validation.
import { EventBridgeSchema, SqsSchema, /* ... */ } from '@aws-lambda-powertools/parser/schemas';// Direct usage
const sqsEvent = SqsSchema.parse(event);
// With parse function
const validatedEvent = parse(event, undefined, EventBridgeSchema);
// With envelope (extracts nested data)
const orders = parse(event, SqsEnvelope, orderSchema);
// Extend with custom validation
const TypedEventBridgeSchema = EventBridgeSchema.extend({
detail: z.object({ orderId: z.string(), amount: z.number() })
});| Schema | Event Type | Key Fields |
|---|---|---|
| APIGatewayProxyEventSchema | REST API v1 | httpMethod, path, body, headers, queryStringParameters, pathParameters |
| APIGatewayProxyEventV2Schema | HTTP API v2 | routeKey, rawPath, body, headers, requestContext |
| APIGatewayProxyWebsocketEventSchema | WebSocket | requestContext.eventType (CONNECT/DISCONNECT/MESSAGE), body |
| APIGatewayRequestAuthorizerEventSchema | REQUEST authorizer | type: 'REQUEST', methodArn, headers |
| APIGatewayTokenAuthorizerEventSchema | TOKEN authorizer | type: 'TOKEN', authorizationToken, methodArn |
| APIGatewayRequestAuthorizerEventV2Schema | HTTP API authorizer | version: '2.0', routeArn, identitySource |
| Schema | Event Type | Key Fields |
|---|---|---|
| AppSyncResolverSchema | Direct resolver | arguments, identity, source, info.fieldName |
| AppSyncBatchResolverSchema | Batch resolver | Array of resolver events |
| AppSyncEventsPublishSchema | Publish event | events[].payload, info.channel.path |
| AppSyncEventsSubscribeSchema | Subscribe event | info.operation: 'SUBSCRIBE' |
| Schema | Event Type | Key Fields |
|---|---|---|
| CloudFormationCustomResourceCreateSchema | Create | RequestType: 'Create', ResourceProperties |
| CloudFormationCustomResourceUpdateSchema | Update | RequestType: 'Update', OldResourceProperties |
| CloudFormationCustomResourceDeleteSchema | Delete | RequestType: 'Delete', PhysicalResourceId |
| Schema | Event Type | Key Fields |
|---|---|---|
| CloudWatchLogsSchema | Log subscription | awslogs.data (auto-decompressed) |
| CloudWatchLogsDecodeSchema | Decoded logs | logGroup, logStream, logEvents[] |
| Schema | Trigger Type | Key Fields |
|---|---|---|
| CreateAuthChallengeTriggerSchema | Create Auth Challenge | request.challengeName, response.{publicChallengeParameters,privateChallengeParameters} |
| CustomEmailSenderTriggerSchema | Custom Email | request.code, request.userAttributes |
| CustomMessageTriggerSchema | Custom Message | request.codeParameter, response.{emailMessage,smsMessage} |
| DefineAuthChallengeTriggerSchema | Define Auth Challenge | request.session[], response.{challengeName,issueTokens} |
| PreSignupTriggerSchema | Pre Signup | request.userAttributes, response.auto{ConfirmUser,VerifyEmail,VerifyPhone} |
| PostAuthenticationTriggerSchema | Post Authentication | request.newDeviceUsed |
| PreTokenGenerationTriggerSchemaV1 | Pre Token Gen v1 | request.groupConfiguration |
| PreTokenGenerationTriggerSchemaV2AndV3 | Pre Token Gen v2/v3 | request.scopes |
| VerifyAuthChallengeTriggerSchema | Verify Challenge | request.challengeAnswer, response.answerCorrect |
| Schema | Event Type | Key Fields |
|---|---|---|
| DynamoDBStreamSchema | Stream event | Records[].{eventName,dynamodb.{NewImage,OldImage}} (auto-unmarshalled) |
| DynamoDBStreamRecord | Single record | eventName: 'INSERT'/'MODIFY'/'REMOVE', dynamodb |
| DynamoDBStreamToKinesisRecord | Stream via Kinesis | tableName, dynamodb (auto-unmarshalled) |
| Schema | Event Type | Key Fields |
|---|---|---|
| EventBridgeSchema | Event | source, detail-type, detail, resources[] |
| Schema | Event Type | Key Fields |
|---|---|---|
| KafkaMskEventSchema | MSK | eventSource: 'aws:kafka', records[topic][] (value auto-decoded) |
| KafkaSelfManagedEventSchema | Self-managed | eventSource: 'SelfManagedKafka', records[topic][] |
| KafkaRecordSchema | Single record | topic, partition, offset, value (auto-decoded), key (auto-decoded) |
| Schema | Event Type | Key Fields |
|---|---|---|
| KinesisDataStreamSchema | Data Stream | Records[].kinesis.data (auto-decoded from base64) |
| KinesisFirehoseSchema | Firehose | records[].data (auto-decoded), deliveryStreamArn |
| KinesisFirehoseSqsSchema | Firehose + SQS | records[].data (decoded as SQS record) |
| KinesisDynamoDBStreamSchema | DynamoDB via Kinesis | Records[].kinesis.data (decoded as DynamoDB record) |
| Schema | Event Type | Key Fields |
|---|---|---|
| S3Schema | S3 notification | Records[].s3.{bucket.name,object.key} |
| S3EventNotificationEventBridgeSchema | S3 via EventBridge | detail.{bucket.name,object.key} |
| S3ObjectLambdaEventSchema | Object Lambda | getObjectContext, userRequest |
| S3SqsEventNotificationSchema | S3 via SQS | Records[].body (parsed as S3 event) |
| Schema | Event Type | Key Fields |
|---|---|---|
| SesSchema | Email receipt | Records[].ses.{mail,receipt.{spamVerdict,virusVerdict}} |
| Schema | Event Type | Key Fields |
|---|---|---|
| SnsSchema | SNS notification | Records[].Sns.{Message,Subject,TopicArn} |
| SnsSqsNotificationSchema | SNS via SQS | Message (from SQS body) |
| Schema | Event Type | Key Fields |
|---|---|---|
| SqsSchema | SQS message | Records[].{body,messageId,receiptHandle,attributes} |
| Schema | Event Type | Key Fields |
|---|---|---|
| AlbSchema | Application Load Balancer | httpMethod, path, body, headers |
| LambdaFunctionUrlSchema | Function URL | version, routeKey, body, headers |
| TransferFamilySchema | Transfer Family auth | username, password, protocol, serverId |
| VpcLatticeSchema | VPC Lattice v1 | method, raw_path, body |
| VpcLatticeV2Schema | VPC Lattice v2 | method, path, body, requestContext |
const OrderEventSchema = EventBridgeSchema.extend({
detail: z.object({
orderId: z.string(),
amount: z.number().positive(),
status: z.enum(['pending', 'completed']),
}),
});
const orderEvent = OrderEventSchema.parse(event);
// orderEvent.detail is now strongly typedconst TypedSqsSchema = z.object({
Records: z.array(
z.object({
body: JSONStringified(z.object({
orderId: z.string(),
items: z.array(z.string()),
})),
messageId: z.string(),
})
),
});
const sqsEvent = TypedSqsSchema.parse(event);
// body is automatically parsed from JSON// Base64-encoded, gzipped JSON in Kinesis
const recordSchema = KinesisDataStreamRecord.extend({
kinesis: z.object({
data: Base64Encoded(JSONStringified(z.object({
userId: z.string(),
action: z.string(),
}))),
}).passthrough(),
});All AWS event types are exported:
import type {
EventBridgeEvent,
SqsEvent,
SqsRecord,
DynamoDBStreamEvent,
S3Event,
// ... and more
} from '@aws-lambda-powertools/parser/types';