AWS.StateStore reference
Source:
src/AWS/StateStore/State.ts
State store backed by an AWS S3 bucket.
Stack state is persisted as JSON objects in an account-regional S3
bucket, laid out exactly like the local state store’s file tree with
the bucket (plus optional prefix) taking the place of the
.alchemy/state directory:
s3://{bucket}/{prefix}{stack}/{stage}/{fqn}.jsons3://{bucket}/{prefix}{stack}/{stage}/__stack_output__.jsonThe bucket is created lazily on the first state operation if it does not already exist — nothing touches AWS credentials at layer construction time.
state: Using the S3 State Store
Section titled “state: Using the S3 State Store”Pass AWS.state() as the state option of a Stack. By default the
state is stored in an account-regional bucket named
alchemy-state-{accountId}-{region}-an.
Default bucket
import * as Alchemy from "alchemy";import * as AWS from "alchemy/AWS";
const Stack = Alchemy.Stack( "my-stack", { providers: AWS.providers(), state: AWS.state() }, Effect.gen(function* () { // ... }),);Custom bucket and key prefix
const Stack = Alchemy.Stack( "my-stack", { providers: AWS.providers(), state: AWS.state({ bucketName: "my-company-state", prefix: "alchemy", encryption: { sseAlgorithm: "aws:kms", kmsMasterKeyId: "alias/alchemy-state", }, }), }, Effect.gen(function* () { // ... }),);state: Managing SSE-C Restrictions
Section titled “state: Managing SSE-C Restrictions”const stateStore = AWS.state({ encryption: { sseAlgorithm: "AES256", blockedEncryptionTypes: ["SSE-C"], },});Omitted blockedEncryptionTypes is equivalent to []: no encryption types
are blocked, so SSE-C writes are permitted via AWS’s NONE value. Removing
an explicit block clears it. Omitting encryption restores AES256, no KMS
key, disabled bucket keys, and no encryption restrictions. Existing objects
are not rewritten.