state
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.
Using the S3 State Store
Section titled “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", }), }, Effect.gen(function* () { // ... }),);