Skip to content
GitHubXDiscordRSS

Schema

Learn how to create, update, and manage AWS EventSchemas Schemas using Alchemy Cloud Control.

The Schema resource allows you to define and manage AWS EventSchemas Schemas for configuring event-driven architectures in AWS.

Create a basic schema with required properties and a description.

import AWS from "alchemy/aws/control";
const basicSchema = await AWS.EventSchemas.Schema("myBasicSchema", {
Type: "openapi3",
Description: "A simple example schema for event management.",
Content: JSON.stringify({
openapi: "3.0.0",
info: {
title: "Sample Schema",
version: "1.0.0"
},
paths: {}
}),
RegistryName: "myEventRegistry"
});

Configure a schema with additional optional properties like SchemaName and Tags for better organization.

const advancedSchema = await AWS.EventSchemas.Schema("myAdvancedSchema", {
Type: "openapi3",
Description: "An advanced schema with additional configurations.",
Content: JSON.stringify({
openapi: "3.0.0",
info: {
title: "Advanced Schema",
version: "1.0.0"
},
paths: {}
}),
RegistryName: "myEventRegistry",
SchemaName: "CustomSchemaName",
Tags: [
{ Key: "Environment", Value: "Production" },
{ Key: "Department", Value: "Finance" }
]
});

Use the adopt option to modify an existing schema without failure.

const adoptSchema = await AWS.EventSchemas.Schema("adoptExistingSchema", {
Type: "openapi3",
Description: "This schema will adopt if it already exists.",
Content: JSON.stringify({
openapi: "3.0.0",
info: {
title: "Adopted Schema",
version: "1.0.0"
},
paths: {}
}),
RegistryName: "myEventRegistry",
adopt: true
});

Define a schema specifically for integrating with an event-driven application.

const eventDrivenSchema = await AWS.EventSchemas.Schema("eventDrivenSchema", {
Type: "cloudwatch",
Description: "Schema designed for event-driven applications.",
Content: JSON.stringify({
type: "object",
properties: {
eventType: { type: "string" },
timestamp: { type: "string", format: "date-time" },
source: { type: "string" }
},
required: ["eventType", "timestamp"]
}),
RegistryName: "myEventRegistry",
Tags: [
{ Key: "UseCase", Value: "Event Processing" }
]
});