AWS.Schemas reference
DescribeCodeBinding
Section titled “DescribeCodeBinding”Source:
src/AWS/Schemas/DescribeCodeBinding.ts
Runtime binding for schemas:DescribeCodeBinding.
Reads the code-binding generation status for the bound Schema in a
target language — poll it after PutCodeBinding until the status is
CREATE_COMPLETE. The registry and schema names are injected from the
binding. Provide the implementation with
Effect.provide(AWS.Schemas.DescribeCodeBindingHttp).
DescribeCodeBinding: Code Bindings
Section titled “DescribeCodeBinding: Code Bindings”// init — bind the operation to the schemaconst describeCodeBinding = yield* AWS.Schemas.DescribeCodeBinding(schema);
// runtimeconst { Status } = yield* describeCodeBinding({ Language: "Python36" });if (Status === "CREATE_COMPLETE") { // the package is ready to download via GetCodeBindingSource}DescribeSchema
Section titled “DescribeSchema”Source:
src/AWS/Schemas/DescribeSchema.ts
Runtime binding for schemas:DescribeSchema.
Reads the bound Schema’s document — the content, type, version,
and description — so a function can fetch the authoritative event contract
at runtime (e.g. to validate incoming payloads against the registered
schema). The registry and schema names are injected from the binding; pass
SchemaVersion to read a specific version instead of the latest. Provide
the implementation with Effect.provide(AWS.Schemas.DescribeSchemaHttp).
DescribeSchema: Reading Schemas
Section titled “DescribeSchema: Reading Schemas”// init — bind the operation to the schemaconst describeSchema = yield* AWS.Schemas.DescribeSchema(schema);
// runtimeconst { Content, SchemaVersion } = yield* describeSchema();const document = JSON.parse(Content!);Discoverer
Section titled “Discoverer”Source:
src/AWS/Schemas/Discoverer.ts
An EventBridge schema discoverer — automatically infers schemas from the
events flowing through an event bus and publishes them (versioned) to the
AWS-managed discovered-schemas registry.
Discoverer: Creating a Discoverer
Section titled “Discoverer: Creating a Discoverer”Discover Schemas on an Event Bus
const bus = yield* AWS.EventBridge.EventBus("AppBus", {});
const discoverer = yield* AWS.Schemas.Discoverer("AppDiscoverer", { sourceArn: bus.eventBusArn, description: "Discovers schemas for application events",});Stopped Discoverer
const discoverer = yield* AWS.Schemas.Discoverer("PausedDiscoverer", { sourceArn: bus.eventBusArn, state: "STOPPED",});The discoverer is provisioned but paused; set state: "STARTED" (or omit
it) to resume discovery.
ExportSchema
Section titled “ExportSchema”Source:
src/AWS/Schemas/ExportSchema.ts
Runtime binding for schemas:ExportSchema.
Exports the bound Schema as a JSONSchema Draft 4 document —
useful when a function needs a portable validation schema for an event
contract that is registered as OpenAPI 3. The registry and schema names
are injected from the binding. Provide the implementation with
Effect.provide(AWS.Schemas.ExportSchemaHttp).
Note: AWS only allows exporting discovered or AWS-managed schemas
(registries discovered-schemas / aws.events). Calling it on a
custom-registry schema fails with a typed ForbiddenException
(You cannot export non discovered or non aws managed schemas.).
ExportSchema: Reading Schemas
Section titled “ExportSchema: Reading Schemas”// init — bind the operation to the schemaconst exportSchema = yield* AWS.Schemas.ExportSchema(schema);
// runtimeconst { Content } = yield* exportSchema({ Type: "JSONSchemaDraft4" });const jsonSchema = JSON.parse(Content!);GetCodeBindingSource
Section titled “GetCodeBindingSource”Source:
src/AWS/Schemas/GetCodeBindingSource.ts
Runtime binding for schemas:GetCodeBindingSource.
Downloads the generated code-binding package (a zip archive, streamed as
Body) for the bound Schema in a target language. Generate the
package first with PutCodeBinding and wait for
DescribeCodeBinding to report CREATE_COMPLETE. The registry and
schema names are injected from the binding. Provide the implementation
with Effect.provide(AWS.Schemas.GetCodeBindingSourceHttp).
GetCodeBindingSource: Code Bindings
Section titled “GetCodeBindingSource: Code Bindings”// init — bind the operation to the schemaconst getCodeBindingSource = yield* AWS.Schemas.GetCodeBindingSource(schema);
// runtime — Body is a Stream of Uint8Array chunks (a zip archive)const { Body } = yield* getCodeBindingSource({ Language: "Python36" });const bytes = yield* Stream.runFold(Body!, 0, (n, chunk) => n + chunk.length);GetDiscoveredSchema
Section titled “GetDiscoveredSchema”Source:
src/AWS/Schemas/GetDiscoveredSchema.ts
Runtime binding for schemas:GetDiscoveredSchema.
Infers an OpenAPI 3 or JSONSchema Draft 4 schema from up to 10 sample
events — the same inference the schema discoverer applies to live traffic,
exposed as an on-demand call. The operation is account-level (it is not
scoped to any registry or schema). Provide the implementation with
Effect.provide(AWS.Schemas.GetDiscoveredSchemaHttp).
GetDiscoveredSchema: Discovering Schemas
Section titled “GetDiscoveredSchema: Discovering Schemas”// init — account-level, no resource to bindconst getDiscoveredSchema = yield* AWS.Schemas.GetDiscoveredSchema();
// runtime — events are full AWS event envelopes as JSON stringsconst { Content } = yield* getDiscoveredSchema({ Type: "OpenApi3", Events: [JSON.stringify(sampleEvent)],});ListSchemaVersions
Section titled “ListSchemaVersions”Source:
src/AWS/Schemas/ListSchemaVersions.ts
Runtime binding for schemas:ListSchemaVersions.
Lists the published versions of the bound Schema so a function can
enumerate the history of an event contract (e.g. to detect that a new
version was published, or to pin consumers to a version range). The
registry and schema names are injected from the binding. Provide the
implementation with Effect.provide(AWS.Schemas.ListSchemaVersionsHttp).
ListSchemaVersions: Reading Schemas
Section titled “ListSchemaVersions: Reading Schemas”// init — bind the operation to the schemaconst listSchemaVersions = yield* AWS.Schemas.ListSchemaVersions(schema);
// runtimeconst { SchemaVersions } = yield* listSchemaVersions();const versions = (SchemaVersions ?? []).map((v) => v.SchemaVersion);PutCodeBinding
Section titled “PutCodeBinding”Source:
src/AWS/Schemas/PutCodeBinding.ts
Runtime binding for schemas:PutCodeBinding.
Kicks off code-binding generation for the bound Schema in a target
language (Java8, Python36, TypeScript3, or Go1). Generation is
asynchronous — poll DescribeCodeBinding until the status is
CREATE_COMPLETE, then download the package with
GetCodeBindingSource. The registry and schema names are injected
from the binding. Provide the implementation with
Effect.provide(AWS.Schemas.PutCodeBindingHttp).
PutCodeBinding: Code Bindings
Section titled “PutCodeBinding: Code Bindings”// init — bind the operation to the schemaconst putCodeBinding = yield* AWS.Schemas.PutCodeBinding(schema);
// runtimeconst { Status } = yield* putCodeBinding({ Language: "Python36" });// Status is "CREATE_IN_PROGRESS" until generation finishesRegistry
Section titled “Registry”Source:
src/AWS/Schemas/Registry.ts
An EventBridge Schema Registry — a named collection of event schemas.
Custom registries hold your own OpenAPI 3 / JSONSchema Draft 4 schema
documents; AWS also maintains the built-in aws.events and
discovered-schemas registries.
Registry: Creating a Registry
Section titled “Registry: Creating a Registry”Basic Registry
const registry = yield* AWS.Schemas.Registry("app-events", { description: "Schemas for application events",});Registry with Tags
const registry = yield* AWS.Schemas.Registry("orders", { description: "Order lifecycle events", tags: { team: "payments" },});Registry: Sharing a Registry
Section titled “Registry: Sharing a Registry”const registry = yield* AWS.Schemas.Registry("shared-events", { policy: { Version: "2012-10-17", Statement: [ { Effect: "Allow", Principal: { AWS: `arn:aws:iam::${otherAccountId}:root` }, Action: ["schemas:DescribeRegistry", "schemas:SearchSchemas"], Resource: registryArn, }, ], },});Registry: Adding Schemas
Section titled “Registry: Adding Schemas”const registry = yield* AWS.Schemas.Registry("app-events", {});const schema = yield* AWS.Schemas.Schema("OrderCreated", { registryName: registry.registryName, type: "OpenApi3", content: JSON.stringify(openApiDocument),});Schema
Section titled “Schema”Source:
src/AWS/Schemas/Schema.ts
An event schema in an EventBridge Schema Registry — a versioned OpenAPI 3 or JSONSchema Draft 4 document describing the structure of an event. Updating the content publishes a new schema version; previous versions are retained by the registry.
Schema: Creating a Schema
Section titled “Schema: Creating a Schema”OpenAPI 3 Schema
const registry = yield* AWS.Schemas.Registry("app-events", {});
const schema = yield* AWS.Schemas.Schema("OrderCreated", { registryName: registry.registryName, type: "OpenApi3", content: JSON.stringify({ openapi: "3.0.0", info: { version: "1.0.0", title: "OrderCreated" }, paths: {}, components: { schemas: { OrderCreated: { type: "object", properties: { orderId: { type: "string" } }, }, }, }, }),});JSONSchema Draft 4 Schema
const schema = yield* AWS.Schemas.Schema("UserSignedUp", { registryName: registry.registryName, type: "JSONSchemaDraft4", content: JSON.stringify({ $schema: "http://json-schema.org/draft-04/schema#", type: "object", properties: { userId: { type: "string" } }, }), description: "Emitted when a user completes sign-up",});SearchSchemas
Section titled “SearchSchemas”Source:
src/AWS/Schemas/SearchSchemas.ts
Runtime binding for schemas:SearchSchemas.
Searches the bound Registry’s schemas by keyword — matching both
schema names and content — so a function can discover event contracts at
runtime. The registry name is injected from the binding. Provide the
implementation with Effect.provide(AWS.Schemas.SearchSchemasHttp).
SearchSchemas: Searching a Registry
Section titled “SearchSchemas: Searching a Registry”// init — bind the operation to the registryconst searchSchemas = yield* AWS.Schemas.SearchSchemas(registry);
// runtimeconst { Schemas } = yield* searchSchemas({ Keywords: "order" });const names = (Schemas ?? []).map((s) => s.SchemaName);StartDiscoverer
Section titled “StartDiscoverer”Source:
src/AWS/Schemas/StartDiscoverer.ts
Runtime binding for schemas:StartDiscoverer.
Resumes schema discovery on the bound Discoverer — e.g. an ops
function re-enabling discovery after a paused window. The discoverer id is
injected from the binding. Provide the implementation with
Effect.provide(AWS.Schemas.StartDiscovererHttp).
StartDiscoverer: Controlling a Discoverer
Section titled “StartDiscoverer: Controlling a Discoverer”// init — bind the operation to the discovererconst startDiscoverer = yield* AWS.Schemas.StartDiscoverer(discoverer);
// runtimeconst { State } = yield* startDiscoverer();// State === "STARTED"StopDiscoverer
Section titled “StopDiscoverer”Source:
src/AWS/Schemas/StopDiscoverer.ts
Runtime binding for schemas:StopDiscoverer.
Pauses schema discovery on the bound Discoverer — e.g. an ops
function halting discovery during a noisy backfill so junk schemas are not
published to the discovered-schemas registry. The discoverer id is
injected from the binding. Provide the implementation with
Effect.provide(AWS.Schemas.StopDiscovererHttp).
StopDiscoverer: Controlling a Discoverer
Section titled “StopDiscoverer: Controlling a Discoverer”// init — bind the operation to the discovererconst stopDiscoverer = yield* AWS.Schemas.StopDiscoverer(discoverer);
// runtimeconst { State } = yield* stopDiscoverer();// State === "STOPPED"