State backend configs tell Forgecroft where to store and read infrastructure state from.
Backend Types
Forgecroft supports two categories of state backend:
Forgecroft-managed — Forgecroft provisions and owns the storage on your behalf. No bucket or credential setup required. Managed state uses Cloudflare R2 under the hood and is available on all plans. Forgecroft configures the state backend for your workspace during onboarding — you do not need to create a state backend config manually.
Bring-your-own — You own and configure the storage. Forgecroft injects the backend block into your workspace’s Terraform config so you don’t need to commit it to your repo.
| Type | Description |
|---|---|
s3 | Amazon S3, or any S3-compatible store (including Forgecroft-managed R2) |
gcs | Google Cloud Storage |
local | Local filesystem (testing only) |
Creating a State Backend Config
POST /state-backend-configs
{
"name": "Production State",
"backend_type": "s3",
"bucket": "my-terraform-state",
"region": "us-east-1",
"credential_config_id": "cred-uuid"
}
| Field | Required | Description |
|---|---|---|
name | Yes | Human-readable name |
backend_type | No | s3 (default), gcs, or local |
bucket | Yes for s3/gcs | Bucket name |
region | No | Region for S3 (omit or use auto for R2) |
endpoint | No | Custom endpoint URL for S3-compatible stores (required for R2) |
credential_config_id | No | Credential config for backend access |
project_id | No | Scope to a specific project |
State Key
The state key is the path within the bucket where state is stored. Set it on the workspace:
PATCH /workspaces/{id}
{ "state_key": "production/vpc" }
If left blank, Forgecroft generates one automatically.
For stacks, the state key is auto-generated as {stack}/{env} (e.g., myapp/dev, myapp/staging).
Backend Credentials
The state backend can use a separate credential config from the cloud provider credentials. This is useful when:
- Your state is in a different AWS account than your infrastructure
- You use a dedicated IAM role for state access
- You need different permissions for state vs. resource operations
Set state_backend_credential_config_id on the workspace to use a different credential for state access.
State Encryption
For sensitive infrastructure, you can encrypt state at rest:
PATCH /workspaces/{id}
{ "state_encryption_config_id": "enc-uuid" }
The encryption config must be of type state_encryption. Forgecroft manages the encryption passphrase as a Kubernetes Secret with automatic garbage collection.
Related API Endpoints
POST /state-backend-configs— Create a state backend configGET /state-backend-configs— List state backend configsPATCH /state-backend-configs/{id}— Update (admin only)DELETE /state-backend-configs/{id}— Delete (409 if workspaces reference it)