AWS.S3Tables reference
GetChannel
Section titled “GetChannel”Source:
packages/aws/src/S3Tables/GetChannel.ts
Runtime binding for the GetChannel operation (IAM action
s3tables:GetChannel on the table ARN): the state of the channel that
PutRows writes the bound Table through, how many rows it
still holds, and the error that blocks its commits when there is one.
The channel exists once PutRows has written to the table; before that
the call fails with the typed NotFoundException. Provide the
implementation with Effect.provide(AWS.S3Tables.GetChannelHttp).
GetChannel: Reading a Channel
Section titled “GetChannel: Reading a Channel”const getChannel = yield* AWS.S3Tables.GetChannel(table);
yield* getChannel().pipe( Effect.repeat({ schedule: Schedule.spaced("5 seconds"), until: (channel) => channel.approximateNumberOfBufferedRows === 0, times: 24, }),);GetTable
Section titled “GetTable”Source:
packages/aws/src/S3Tables/GetTable.ts
Runtime binding for the GetTable operation (IAM action
s3tables:GetTable on the table ARN).
Reads the bound Table’s details — its current versionToken,
metadataLocation, warehouseLocation, and format. The version token and
metadata location are the inputs to the Iceberg commit protocol (see
UpdateTableMetadataLocation). Provide the implementation with
Effect.provide(AWS.S3Tables.GetTableHttp).
GetTable: Reading Table Metadata
Section titled “GetTable: Reading Table Metadata”const getTable = yield* AWS.S3Tables.GetTable(table);
const { versionToken, metadataLocation, warehouseLocation } = yield* getTable();GetTableMaintenanceJobStatus
Section titled “GetTableMaintenanceJobStatus”Source:
packages/aws/src/S3Tables/GetTableMaintenanceJobStatus.ts
Runtime binding for the GetTableMaintenanceJobStatus operation (IAM
action s3tables:GetTableMaintenanceJobStatus on the table ARN).
Reads the status of the bound Table’s managed maintenance jobs —
Iceberg compaction and snapshot management — including when each job last
ran and whether it succeeded. Useful for compute that monitors table
health at runtime. Provide the implementation with
Effect.provide(AWS.S3Tables.GetTableMaintenanceJobStatusHttp).
GetTableMaintenanceJobStatus: Monitoring Maintenance
Section titled “GetTableMaintenanceJobStatus: Monitoring Maintenance”const getTableMaintenanceJobStatus = yield* AWS.S3Tables.GetTableMaintenanceJobStatus(table);
const { status } = yield* getTableMaintenanceJobStatus();for (const [job, state] of Object.entries(status)) { yield* Effect.log(`${job}: ${state?.status}`);}GetTableMetadataLocation
Section titled “GetTableMetadataLocation”Source:
packages/aws/src/S3Tables/GetTableMetadataLocation.ts
Runtime binding for the GetTableMetadataLocation operation (IAM action
s3tables:GetTableMetadataLocation on the table ARN).
Reads the bound Table’s current metadata location and version
token — the read half of the Iceberg commit protocol: read the current
metadata, write a new metadata file to the warehouse, then commit it with
UpdateTableMetadataLocation. Provide the implementation with
Effect.provide(AWS.S3Tables.GetTableMetadataLocationHttp).
GetTableMetadataLocation: The Iceberg Commit Protocol
Section titled “GetTableMetadataLocation: The Iceberg Commit Protocol”const getTableMetadataLocation = yield* AWS.S3Tables.GetTableMetadataLocation(table);
const { versionToken, metadataLocation, warehouseLocation } = yield* getTableMetadataLocation();ListNamespaces
Section titled “ListNamespaces”Source:
packages/aws/src/S3Tables/ListNamespaces.ts
Runtime binding for the ListNamespaces operation (IAM action
s3tables:ListNamespaces on the table bucket ARN).
Lists the namespaces in the bound TableBucket — the catalog’s
databases. Useful for compute that discovers tables dynamically at
runtime. Provide the implementation with
Effect.provide(AWS.S3Tables.ListNamespacesHttp).
ListNamespaces: Discovering Namespaces and Tables
Section titled “ListNamespaces: Discovering Namespaces and Tables”const listNamespaces = yield* AWS.S3Tables.ListNamespaces(bucket);
const { namespaces } = yield* listNamespaces();for (const ns of namespaces) { yield* Effect.log(`namespace: ${ns.namespace[0]}`);}ListTables
Section titled “ListTables”Source:
packages/aws/src/S3Tables/ListTables.ts
Runtime binding for the ListTables operation (IAM action
s3tables:ListTables on the table bucket ARN).
Lists the tables in the bound TableBucket, optionally filtered to
a namespace or name prefix. Useful for compute that enumerates the
catalog at runtime. Provide the implementation with
Effect.provide(AWS.S3Tables.ListTablesHttp).
ListTables: Discovering Namespaces and Tables
Section titled “ListTables: Discovering Namespaces and Tables”const listTables = yield* AWS.S3Tables.ListTables(bucket);
const { tables } = yield* listTables({ namespace: "events" });for (const table of tables) { yield* Effect.log(`table: ${table.name}`);}Namespace
Section titled “Namespace”Source:
packages/aws/src/S3Tables/Namespace.ts
A namespace within an Amazon S3 Tables TableBucket — a logical
grouping of Tables, equivalent to a database in an Iceberg catalog.
Namespace: Creating Namespaces
Section titled “Namespace: Creating Namespaces”Basic Namespace
import * as S3Tables from "@alchemy.run/aws/S3Tables";
const bucket = yield* S3Tables.TableBucket("Analytics");const ns = yield* S3Tables.Namespace("Events", { tableBucket: bucket.tableBucketArn,});Named Namespace
const ns = yield* S3Tables.Namespace("Events", { tableBucket: bucket.tableBucketArn, namespace: "raw_events",});Namespace: Looking up an existing namespace
Section titled “Namespace: Looking up an existing namespace”Namespace.lookup references a namespace Alchemy doesn’t manage (created in the
console or by another stack), found by tableBucketArn and namespace. It is read during
plan/deploy and never created, updated or deleted.
const sales = AWS.S3Tables.Namespace.lookup({ tableBucketArn, namespace: "sales" });PutRows
Section titled “PutRows”Source:
packages/aws/src/S3Tables/PutRows.ts
Runtime binding for the PutRows operation: write rows straight into the
bound Iceberg Table. The service checks each row against the
table’s schema, writes the Parquet files and commits them, usually within
a minute. There is no s3tables:PutRows IAM action; the binding grants
s3tables:GetTableData, s3tables:PutTableData,
s3tables:GetTableMetadataLocation and
s3tables:UpdateTableMetadataLocation on the table ARN.
A request carries up to 50 MiB and 500,000 rows, as newline-delimited
JSON or one Avro Object Container File. Provide the implementation with
Effect.provide(AWS.S3Tables.PutRowsHttp).
PutRows: Writing Rows
Section titled “PutRows: Writing Rows”const putRows = yield* AWS.S3Tables.PutRows(table);
const { acceptedRows } = yield* putRows({ payloadFormat: "JSON", payload: new TextEncoder().encode( events.map((event) => JSON.stringify(event)).join("\n"), ),});StorageLensConfiguration
Section titled “StorageLensConfiguration”Source:
packages/aws/src/S3Tables/StorageLensConfiguration.ts
An Amazon S3 Storage Lens for Tables configuration: daily metrics about how the data in your S3 table buckets is stored, accessed and maintained.
The Region the stack deploys to becomes the configuration’s home Region,
which can’t change later. A configuration can still report on table buckets
in other Regions. Every configuration collects the free basic storage
metrics; advancedMetricsCategories adds billed ones.
StorageLensConfiguration: Creating a configuration
Section titled “StorageLensConfiguration: Creating a configuration”Basic metrics for every table bucket
import * as S3Tables from "@alchemy.run/aws/S3Tables";
const lens = yield* S3Tables.StorageLensConfiguration("Lens");Scope to one table bucket
const bucket = yield* S3Tables.TableBucket("Analytics");
const lens = yield* S3Tables.StorageLensConfiguration("Lens", { include: { tableBuckets: [bucket.tableBucketArn] },});Exclude a Region
const lens = yield* S3Tables.StorageLensConfiguration("Lens", { exclude: { regions: ["eu-west-1"] },});StorageLensConfiguration: Advanced metrics
Section titled “StorageLensConfiguration: Advanced metrics”const lens = yield* S3Tables.StorageLensConfiguration("Lens", { advancedMetricsCategories: ["ActivityMetrics", "MaintenanceMetrics"],});StorageLensConfiguration: Exporting metrics
Section titled “StorageLensConfiguration: Exporting metrics”Export to queryable tables
const lens = yield* S3Tables.StorageLensConfiguration("Lens", { dataExport: { table: true },});Export Parquet files to a bucket and publish to CloudWatch
const metrics = yield* S3.Bucket("Metrics");
const lens = yield* S3Tables.StorageLensConfiguration("Lens", { dataExport: { cloudWatchMetrics: true, s3Bucket: { arn: metrics.bucketArn, accountId: metrics.accountId, format: "Parquet", prefix: "storage-lens/", }, },});Export to KMS-encrypted tables
const lens = yield* S3Tables.StorageLensConfiguration("Lens", { dataExport: { table: { encryption: { sseAlgorithm: "aws:kms", kmsKeyArn: key.keyArn } }, },});StorageLensConfiguration: Organization-level configuration
Section titled “StorageLensConfiguration: Organization-level configuration”const lens = yield* S3Tables.StorageLensConfiguration("Lens", { awsOrg: "arn:aws:organizations::111122223333:organization/o-abc123",});StorageLensConfiguration: Pausing a configuration
Section titled “StorageLensConfiguration: Pausing a configuration”const lens = yield* S3Tables.StorageLensConfiguration("Lens", { isEnabled: false,});Source:
packages/aws/src/S3Tables/Table.ts
A fully-managed Apache Iceberg table within an S3 Tables Namespace.
S3 Tables manages the table’s storage, metadata, and maintenance (compaction, snapshot expiration). Query it through engines like Amazon Athena, Amazon EMR, or Apache Spark via the S3 Tables Iceberg catalog.
Table: Creating Tables
Section titled “Table: Creating Tables”import * as S3Tables from "@alchemy.run/aws/S3Tables";
const bucket = yield* S3Tables.TableBucket("Analytics");const ns = yield* S3Tables.Namespace("Events", { tableBucket: bucket.tableBucketArn,});const table = yield* S3Tables.Table("PageViews", { tableBucket: bucket.tableBucketArn, namespace: ns.namespace, schema: { fields: [ { name: "id", type: "long", required: true }, { name: "url", type: "string" }, { name: "ts", type: "timestamp" }, ], },});Table: Looking up an existing table
Section titled “Table: Looking up an existing table”Table.lookup references a table Alchemy doesn’t manage (created in the
console or by another stack), found by tableBucketArn, namespace and name. It is read during
plan/deploy and never created, updated or deleted.
const orders = AWS.S3Tables.Table.lookup({ tableBucketArn, namespace: "sales", name: "orders" });TableBucket
Section titled “TableBucket”Source:
packages/aws/src/S3Tables/TableBucket.ts
An Amazon S3 Tables table bucket — a purpose-built bucket for storing fully-managed Apache Iceberg tables.
A table bucket is regional and holds Namespaces, which in turn hold
Tables. The bucket name is auto-generated from the app, stage, and
logical ID unless you provide one explicitly.
TableBucket: Creating Table Buckets
Section titled “TableBucket: Creating Table Buckets”Basic Table Bucket
import * as S3Tables from "@alchemy.run/aws/S3Tables";
const bucket = yield* S3Tables.TableBucket("Analytics");Named Table Bucket
const bucket = yield* S3Tables.TableBucket("Analytics", { name: "my-analytics-tables",});TableBucket: Encryption
Section titled “TableBucket: Encryption”const bucket = yield* S3Tables.TableBucket("Secure", { encryptionConfiguration: { sseAlgorithm: "aws:kms", kmsKeyArn: key.keyArn, },});TableBucket: Looking up an existing table bucket
Section titled “TableBucket: Looking up an existing table bucket”TableBucket.lookup references a table bucket Alchemy doesn’t manage (created in the
console or by another stack), found by tableBucketArn or name. It is read during
plan/deploy and never created, updated or deleted.
const lake = AWS.S3Tables.TableBucket.lookup({ name: "lake" });const tableBucketArn = lake.tableBucketArn;UpdateTableMetadataLocation
Section titled “UpdateTableMetadataLocation”Source:
packages/aws/src/S3Tables/UpdateTableMetadataLocation.ts
Runtime binding for the UpdateTableMetadataLocation operation (IAM
action s3tables:UpdateTableMetadataLocation on the table ARN).
Commits a new Iceberg metadata file for the bound Table — the
write half of the Iceberg commit protocol: read the current version with
GetTableMetadataLocation, write a new metadata file into the
table’s warehouse, then commit it here with the observed versionToken.
A stale token fails with the typed ConflictException (another writer
committed first). Provide the implementation with
Effect.provide(AWS.S3Tables.UpdateTableMetadataLocationHttp).
UpdateTableMetadataLocation: The Iceberg Commit Protocol
Section titled “UpdateTableMetadataLocation: The Iceberg Commit Protocol”const getTableMetadataLocation = yield* AWS.S3Tables.GetTableMetadataLocation(table);const updateTableMetadataLocation = yield* AWS.S3Tables.UpdateTableMetadataLocation(table);
const { versionToken, warehouseLocation } = yield* getTableMetadataLocation();// ... write `${warehouseLocation}/metadata/00001-….metadata.json` ...yield* updateTableMetadataLocation({ versionToken, metadataLocation: `${warehouseLocation}/metadata/00001-….metadata.json`,});