Infrastructure as Code

Infrastructure as Code

Export projects and apps as manifests, preview changes, apply them, and tear them down.

Infrastructure as Code is opt-in and off by default for each project. Check with stackblaze status; export, plan, apply and destroy refuse when it is off.

The manifests are YAML documents in the format stackblaze export writes, one per project and one per app. App documents need metadata.pipeline and metadata.phase. A path can be a file or a directory (all .yaml and .yml files, recursively). This is separate from the stackblaze.yaml blueprint file.

stackblaze status

Checks that the API is reachable with your credentials and reports whether Infrastructure as Code is enabled. Pass --pipeline (or run in a linked directory) to check one project. With an app in scope it also shows that app's state, for example paused. Exits 0 whether IaC is on or off.

usage
stackblaze status

Also accepts the scope flags (-p, --pipeline, --phase, -a, --app) and the output flags (-o, --output, --json), plus --token and --api-url. Common flags

Examples

terminal
stackblaze status -p shop

stackblaze export

Writes one YAML file per project and per app that plan and apply accept. Exported app files include variable values, so review them before committing.

usage
stackblaze export [--out <dir>] [-p <project>]
FlagDescription
--out <dir>Output directory (default stackblaze)
-p, --pipeline <name>Export one project (default: all you can see)

Also accepts the output flags (-o, --output, --json), plus --token and --api-url. Common flags

Examples

terminal
stackblaze export --out ./infra -p shop

stackblaze plan

Compares the manifests with what is live and prints what apply would create or update, with a diff for updates. Nothing is changed.

usage
stackblaze plan <path>

Also accepts the output flags (-o, --output, --json), plus --token and --api-url. Common flags

Examples

terminal
stackblaze plan ./stackblaze

stackblaze apply

Creates or updates every project and app declared in the manifests, projects first. It never deletes. Exits 1 if any resource failed.

usage
stackblaze apply <path> [--continue-on-error]
FlagDescription
--continue-on-errorKeep going after a resource fails (default: stop at the first failure)

Also accepts the output flags (-o, --output, --json), plus --token and --api-url. Common flags

Examples

terminal
stackblaze plan ./stackblaze && stackblaze apply ./stackblaze

stackblaze destroy

Deletes every resource declared in the manifests, apps first, then projects. Lists what will be deleted and asks you to type yes unless -y. Exits 1 if any deletion failed.

usage
stackblaze destroy <path> [-y]
FlagDescription
-y, --yesDo not prompt

Also accepts the output flags (-o, --output, --json), plus --token and --api-url. Common flags

Examples

terminal
stackblaze destroy ./stackblaze -y