Stackform documentation
Overview
Everything you need to connect your AWS account, prepare your CDK project, and deploy infrastructure through Stackform.
Stackform deploys your AWS CDK projects to any AWS account using short-lived OIDC credentials. There are no long-lived keys, no standing access, and full ownership stays with you.
- 1. ConnectLink your AWS account and Git repository
- 2. ConfigureSet environment variables and choose a branch
- 3. DeployOne click or auto-deploy on push
Under the hood, Stackform clones your repo, installs dependencies, synthesizes the CDK app, bootstraps the target account, and deploys all stacks. Logs stream in real-time to the Stackform dashboard.
AWS Account Setup
Stackform uses OIDC federation to securely assume a role in your AWS account. No long-lived credentials are stored. This setup is done once per AWS account.
1. Create the OIDC Identity Provider
Tell AWS to trust Stackform as an identity provider:
aws iam create-open-id-connect-provider \--url "https://app.stackform.io" \--client-id-list "sts.amazonaws.com" \--thumbprint-list "6e389d173df252c45ef9ba108af64e32771901b1"
Save the returned OpenIDConnectProviderArn for the next step.
2. Create the IAM Role with Trust Policy
Create a file stackform-trust-policy.json:
{"Version": "2012-10-17","Statement": [{"Effect": "Allow","Principal": {"Federated": "arn:aws:iam::YOUR_ACCOUNT_ID:oidc-provider/app.stackform.io"},"Action": "sts:AssumeRoleWithWebIdentity","Condition": {"StringEquals": {"app.stackform.io:aud": "sts.amazonaws.com"}}}]}
Then create the role:
aws iam create-role \--role-name StackformDeployRole \--assume-role-policy-document file://stackform-trust-policy.json \--description "Allows Stackform to deploy CDK infrastructure"
3. Attach Deployment Permissions
For development and testing, you can use AdministratorAccess:
aws iam attach-role-policy \--role-name StackformDeployRole \--policy-arn arn:aws:iam::aws:policy/AdministratorAccess
Example custom policy for production
{"Version": "2012-10-17","Statement": [{"Effect": "Allow","Action": ["cloudformation:*","s3:*","lambda:*","iam:GetRole","iam:CreateRole","iam:DeleteRole","iam:AttachRolePolicy","iam:DetachRolePolicy","iam:PutRolePolicy","iam:DeleteRolePolicy","iam:PassRole","logs:*","apigateway:*","dynamodb:*","ec2:DescribeAvailabilityZones","ec2:DescribeVpcs","ec2:DescribeSubnets","ec2:DescribeSecurityGroups"],"Resource": "*"}]}
4. Provide the Role ARN to Stackform
Copy your role ARN and add it in the Stackform platform when connecting your AWS account:
aws iam get-role --role-name StackformDeployRole \--query 'Role.Arn' --output text
The ARN looks like: arn:aws:iam::123456789012:role/StackformDeployRole
Optional: restrict to specific repositories
Add a StringLike condition to the trust policy to scope deployments:
"Condition": {"StringEquals": {"app.stackform.io:aud": "sts.amazonaws.com"},"StringLike": {"app.stackform.io:sub": "repo:your-org/*"}}
Setup via AWS Console
If you prefer the AWS Management Console over the CLI, follow these steps.
1. Create OIDC Identity Provider
- Go to IAM → Identity providers → Add provider
- Select OpenID Connect and enter the values below
- Click Get thumbprint, then Add provider
2. Create IAM Role
- Go to IAM → Roles → Create role
- Trusted entity: Web identity
- Provider: app.stackform.io, Audience: sts.amazonaws.com
- Attach your chosen permissions policy
- Name the role as below
3. Copy Role ARN
Click on the role and copy the ARN from the summary page. Provide it to Stackform along with your preferred AWS region.
CDK Project Requirements
Your CDK project must meet these requirements to deploy through Stackform.
Mandatory files
| File | Purpose |
|---|---|
| cdk.json | Must exist at repo root with a valid "app" entry (e.g. "npx ts-node bin/app.ts") |
| package.json + lockfile | Lockfile must be committed and in sync. Supports npm, pnpm, yarn, and bun. |
Example cdk.json
{"app": "npx ts-node bin/app.ts"}
Recommended CDK app pattern
const app = new cdk.App();const stackName = process.env.STACK_NAME || "my-default-stack";new MyStack(app, stackName, {env: {account: process.env.ACCOUNT_ID || process.env.CDK_DEFAULT_ACCOUNT,region: process.env.ACCOUNT_REGION || process.env.CDK_DEFAULT_REGION,},});
ACCOUNT_ID, ACCOUNT_REGION, and STACK_NAME.Package manager support
| Lockfile | Package Manager | Install Command |
|---|---|---|
| bun.lockb / bun.lock | bun | bun install --frozen-lockfile |
| pnpm-lock.yaml | pnpm | pnpm install --frozen-lockfile |
| yarn.lock | yarn | yarn install --immutable |
| package-lock.json | npm | npm ci |
Container runtime limits
| Resource | Limit |
|---|---|
| RAM | 4 GB |
| CPU | 2 vCPU (x86_64) |
| Ephemeral storage | 30 GB |
| Credential lifetime | 1 hour |
| Node.js | 22 (LTS) |
Multi-stack behavior
Stackform deploys all stacks in the synthesized assembly. You cannot selectively deploy individual stacks. Use CDK Stage constructs or conditional logic to control which stacks are synthesized.
Known limitations
- No Docker-in-Docker —
DockerImageAssetwill fail. Pre-build images and reference them by ECR URI. - Node.js only — Python CDK projects are not supported in the current runtime.
- No SSM/Secrets Manager at runtime — pass secrets through Stackform environment config.
Environments & Secrets
Configure environment variables and secrets in the Stackform UI. They are injected into your CDK process during synthesis and deployment.
System variables
These are automatically available during synthesis:
| Variable | Description |
|---|---|
| ACCOUNT_ID | Target AWS account ID |
| ACCOUNT_REGION | Target AWS region |
| STACK_NAME | Auto-generated CloudFormation stack name |
SSM Parameter Store secrets
Prefix a variable value with ssm:// to resolve it from SSM Parameter Store before deployment:
DATABASE_URL=ssm:///my-app/prod/database-urlThe value is resolved by the deploy-trigger Lambda and injected as a plain-text environment variable. Your CDK code reads it as process.env.DATABASE_URL.
Deploying
Trigger a deployment from the Stackform dashboard or via auto-deploy on Git push.
Deployment flow
- INITIALIZING
- CLONING
- INSTALLING
- SYNTHESIZING
- BOOTSTRAPPING
- DEPLOYING
- TAGGING
- ARCHIVING
- COMPLETED
Each phase streams real-time logs to the Stackform dashboard. Deployments that fail will have CloudFormation automatically roll back the stack.
Deployment statuses
| Status | Meaning |
|---|---|
| PENDING | Deployment created, container launching |
| SYNTHESIZING | Installing deps and running CDK synthesis |
| DEPLOYING | CloudFormation stack create/update in progress |
| COMPLETED | All stacks deployed successfully |
| FAILED | Error during any phase (check logs) |
| DESTROYING | Stack deletion in progress |
| DESTROYED | Stack deleted successfully |
| ROLLING_BACK | CloudFormation rollback in progress |
Auto-deploy on Git Push
Automatically deploy when code is pushed to a branch. Enable auto-deploy on any environment in the Stackform UI.
How it works
- Enable Auto-deploy on an environment and select a branch
- Stackform registers a webhook on your GitHub repository
- On push to the configured branch, Stackform validates the webhook signature and triggers a deployment
- Multiple projects sharing the same repo can each deploy to different AWS accounts
Example: multi-project setup
Repo: github.com/acme/infraProject A (Org 1)Environment "prod" (branch: main) -> AWS 111111111111Environment "staging" (branch: develop) -> AWS 111111111111Project B (Org 2)Environment "prod" (branch: main) -> AWS 222222222222Push to main -> deploys Project A prod + Project B prodPush to develop -> deploys Project A staging only
Security
- Every webhook payload is validated with SHA-256 HMAC
- Timing-safe comparison prevents timing attacks
- Each organization has its own webhook secret
Redeploy & Rollback
Redeploy from a previously successful deployment without cloning or rebuilding. Useful for fixing drift, retrying, or rolling back to a known-good state.
How redeploy works
- Every successful deployment archives its
cdk.outto S3 - Redeploy downloads the stored assembly and deploys it directly — no clone, install, or synthesis
- The engine is automatically selected based on the original deployment duration
- INITIALIZING
- DOWNLOADING
- BOOTSTRAPPING
- DEPLOYING
- TAGGING
- COMPLETED
Troubleshooting
npm ci fails with "lockfile out of sync"
Run npm install locally and commit the updated package-lock.json.
postinstall scripts fail because of missing AWS credentials
AWS credentials are scrubbed from the environment during npm install for security. Move credential-dependent logic to synthesis or deployment time.
Deploy fails with wrong account/region
Do not hardcode account IDs or regions. Use process.env.ACCOUNT_ID and process.env.ACCOUNT_REGION.
"Cannot connect to the Docker daemon"
Docker-in-Docker is not available in the Fargate container. Pre-build Docker images and reference them by ECR URI using ContainerImage.fromEcrRepository().
Deployment exceeds 1-hour credential window
STS credentials last 1 hour. Reduce stack complexity or split into smaller stacks. Large ECS/RDS deployments taking more than 45 minutes may hit this limit.
cdk.context.json lookups fail
Commit cdk.context.json with resolved values, or use alternatives that accept explicit values instead of fromLookup.
"Stack already exists" error
A CloudFormation stack with the same name already exists from a previous manual deployment. Delete or import the existing stack, or rename your Stackform project/environment to generate a different stack name.
Webhook not triggering auto-deploy
- Verify the environment has
autoDeployEnabledset to true - Check the branch matches the push branch
- Confirm no deployment is already in progress for that environment
"Access Denied" during deployments
The IAM role attached to the OIDC provider does not have sufficient permissions. Review the attached policies:
aws iam list-attached-role-policies --role-name StackformDeployRolePre-deployment checklist
Project Structure
- cdk.json exists at repository root with a valid app entry
- app command uses npx or references a local dependency
- Lockfile is committed and in sync with package.json
- cdk.context.json is committed (if using context lookups)
CDK Code
- Account/region read from environment variables, not hardcoded
- No DockerImageAsset (no Docker-in-Docker)
- All stacks target the same account and region
- No interactive prompts during synthesis
- Stack names accept STACK_NAME env var
Environment & Secrets
- All required env vars defined in Stackform environment config
- Secrets referenced with ssm:// prefix
- No direct SSM/Secrets Manager calls at synthesis time
Target Account
- IAM role exists and trusts Stackform OIDC provider
- Role has sufficient permissions for all resources
- No SCPs blocking CloudFormation or CDK bootstrap
Need help?
Contact us with your AWS Account ID and the error message you received.