Skip to content

AWS.Schemas reference

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).

// init — bind the operation to the schema
const describeCodeBinding = yield* AWS.Schemas.DescribeCodeBinding(schema);
// runtime
const { Status } = yield* describeCodeBinding({ Language: "Python36" });
if (Status === "CREATE_COMPLETE") {
// the package is ready to download via GetCodeBindingSource
}

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).

// init — bind the operation to the schema
const describeSchema = yield* AWS.Schemas.DescribeSchema(schema);
// runtime
const { Content, SchemaVersion } = yield* describeSchema();
const document = JSON.parse(Content!);

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.

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.

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.).

// init — bind the operation to the schema
const exportSchema = yield* AWS.Schemas.ExportSchema(schema);
// runtime
const { Content } = yield* exportSchema({ Type: "JSONSchemaDraft4" });
const jsonSchema = JSON.parse(Content!);

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).

// init — bind the operation to the schema
const 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);

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).

// init — account-level, no resource to bind
const getDiscoveredSchema = yield* AWS.Schemas.GetDiscoveredSchema();
// runtime — events are full AWS event envelopes as JSON strings
const { Content } = yield* getDiscoveredSchema({
Type: "OpenApi3",
Events: [JSON.stringify(sampleEvent)],
});

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).

// init — bind the operation to the schema
const listSchemaVersions = yield* AWS.Schemas.ListSchemaVersions(schema);
// runtime
const { SchemaVersions } = yield* listSchemaVersions();
const versions = (SchemaVersions ?? []).map((v) => v.SchemaVersion);

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).

// init — bind the operation to the schema
const putCodeBinding = yield* AWS.Schemas.PutCodeBinding(schema);
// runtime
const { Status } = yield* putCodeBinding({ Language: "Python36" });
// Status is "CREATE_IN_PROGRESS" until generation finishes

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.

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" },
});
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,
},
],
},
});
const registry = yield* AWS.Schemas.Registry("app-events", {});
const schema = yield* AWS.Schemas.Schema("OrderCreated", {
registryName: registry.registryName,
type: "OpenApi3",
content: JSON.stringify(openApiDocument),
});

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.

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",
});

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).

// init — bind the operation to the registry
const searchSchemas = yield* AWS.Schemas.SearchSchemas(registry);
// runtime
const { Schemas } = yield* searchSchemas({ Keywords: "order" });
const names = (Schemas ?? []).map((s) => s.SchemaName);

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).

// init — bind the operation to the discoverer
const startDiscoverer = yield* AWS.Schemas.StartDiscoverer(discoverer);
// runtime
const { State } = yield* startDiscoverer();
// State === "STARTED"

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).

// init — bind the operation to the discoverer
const stopDiscoverer = yield* AWS.Schemas.StopDiscoverer(discoverer);
// runtime
const { State } = yield* stopDiscoverer();
// State === "STOPPED"