Use Atmos
Optional: hand this page to your coding agentThe steps work by hand too.Show the whole prompt
Read https://intentius.io/terragucci/guides/use-atmos/.
Run `npx terragucci init --dry-run --json`, list the instances and waves it found,
tell me about any instance it refused and why, and open a pull request with the pipeline.
Never apply, approve (a pull request review or `terragucci approve`), override a policy denial (`terragucci override`), use `--mode apply`, or merge; never touch `.chant/allowed_signers` or `chant/lifecycle`.Result
Section titled “Result”A pipeline whose roots are your Atmos component instances, one per stack and component, applied a dependency layer at a time behind the same gate as plain roots.
Already in Atmos
Section titled “Already in Atmos”Atmos and Atmos Pro already do part of this work:
| Feature | What it does |
|---|---|
| Ordered deployments (Atmos Pro) | on merge, applies parent stacks first and starts a child only once its parents succeed |
| Apply on merge | downloads the plan stored in the pull request, plans again and compares the two, failing on drift by default |
| Deploy affected | fans out over the changed components as a CI matrix of component and stack |
| Planfile storage | stores each plan with a SHA256 checksum and checks it before the deploy |
| Drift detection (Atmos Pro) | checks for drift from a workflow that runs daily and on every merge |
If Atmos Pro’s ordered deployments and apply on merge already fit your team, you may not need terragucci’s waves or its stale-plan refusal.
Atmos’s own YAML functions also go further than terragucci’s reading of them. When it describes the stacks, terragucci refuses !store and leaves !terraform.output unevaluated, then reads the output itself as described in Reads of another instance.
Added by terragucci
Section titled “Added by terragucci”- An approval binds the wave’s plan digest and counts only from someone with no hand in the change. Atmos Pro leaves approvals to GitHub’s environment protection rules, and its docs note that required reviewers on a private repo need GitHub Enterprise.
- No hosted service takes part. The jobs run in your CI and keep their records in your git and your bucket.
initwrites the pipeline for GitLab and Forgejo as well as GitHub.
Prerequisites
Section titled “Prerequisites”| You need | Why |
|---|---|
An atmos.yaml at the repo root |
init detects Atmos from it |
Atmos on the path, or TERRAGUCCI_ATMOS naming it |
init runs atmos describe stacks |
A remote backend for each instance, such as s3 |
each job starts from a fresh checkout |
| terragucci installed (Get your first plan note) | init writes the pipeline |
-
Run init.
Terminal window npx terragucci init --dry-runIt prints the instances and how many waves they make:
found Atmos (atmos.yaml): 4 instances in 2 waves from atmos describe stacks, ... -
Write the pipeline.
Terminal window npx terragucci initCommit it and open a pull request.
Instances
Section titled “Instances”| What | How |
|---|---|
| A root | one instance, named <stack>/<component>, such as prod/vpc |
| Which instances | every Terraform instance atmos describe stacks lists, less abstract ones (metadata.type: abstract) and disabled ones (metadata.enabled: false) |
roots and synth |
refused: the stacks decide the roots |
An instance that sets env or generate |
refused; move the setting into the component’s Terraform, or disable the instance |
Refused settings
Section titled “Refused settings”terragucci atmos write makes each instance’s directory as a copy, so config check and init refuse settings that would edit it:
| Setting | Instead |
|---|---|
drift with the drift pull request, the default respond.drift |
respond.drift: attribute or off; a live value belongs in the stack’s vars or the component |
rollouts |
move the pin in the component, which every instance of it shares |
generate |
the stack’s backend and providers settings |
ephemeral |
none |
| What | How |
|---|---|
| Order | dependencies.components, and settings.depends_on; an entry with no stack means the instance’s own stack |
A read with !terraform.state or !terraform.output |
puts the instance after the one it reads |
| Each wave | one dependency layer, in its own apply job behind its own gate |
| A dependency on a disabled instance | holds nothing back |
| A dependency no stack deploys, or a cycle | init stops and names it |
waves.canary |
the canary instances’ layers go first |
Before reading the roots, every job installs Atmos 1.230.1 (checked against the release’s SHA256SUMS) and runs terragucci atmos write. For another release, set it in terragucci.yml and rerun init:
atmos:
version: 1.230.0The check job runs atmos validate stacks first, so a manifest Atmos refuses fails the check with Atmos’s own error.
terragucci atmos write |
|
|---|---|
| Reads | atmos describe stacks, with !terraform.state, !terraform.output and !store left unevaluated |
| Writes | the component’s Terraform to <stack>/<component>, with the varfile, backend and provider override Atmos generates for that instance |
| Local module sources | a ../ source outside the component is rewritten to reach the same directory from the copy |
A directory of your repo at <stack>/<component> |
refused |
These directories are made in the job. If you run terragucci atmos write yourself, add them to .gitignore.
Workspaces
Section titled “Workspaces”Each instance plans and applies in the Terraform workspace Atmos names for it, never default. With an s3 backend its state is at <workspace_key_prefix>/<workspace>/<key>, as Atmos keeps it.
terragucci plan, unlock-state, state export and a state migration run each instance in its workspace too.
The tip pull requests pin providers and add lock files in the components, which git holds, and name instances in a canary wave.
Pull requests
Section titled “Pull requests”A pull request plans the instances whose written files differ from the base’s, and every instance that depends on one of them. The plan job also writes the instances at the base and compares the two without a cloud credential. Roots a change plans compares this with the other repo shapes.
| A pull request that changes | Plans |
|---|---|
prod/vpc’s vars |
prod/vpc, then prod/app, which depends on it |
| a component’s Terraform | every instance of that component, and their dependents |
| nothing an instance is written from | nothing |
Approval
Section titled “Approval”A wave applies the plans whose digest was approved, as plain roots do. If the stacks change after the approval, the wave plans again and applies nothing. It names the instances that moved; approve the new plans to apply them.
Reads of another instance
Section titled “Reads of another instance”A var set with !terraform.state or !terraform.output reads another instance’s outputs:
components:
terraform:
app:
vars:
vpc_cidr: !terraform.state vpc .cidratmos describe stacks runs before the job has a cloud credential, so the job reads the value itself afterwards from the state in the upstream’s own workspace. While the upstream has no state, the instance is held back rather than planned on a stand-in; the plan note names the instance it waits for.
A pull request reads the upstream’s applied state, never its plan. When one change edits both instances, the review shows the reader planned on the upstream’s old value. After the merge, the reader’s wave plans on what the upstream’s wave applied, which nobody reviewed. When the upstream’s plan in that push changes an output the reader reads, or leaves it known only after apply, the reader’s wave waits for an approval of its plan even under gate: on-destructive with nothing destroyed; only gate: never applies it without one. The wave’s log names the read, the outputs and the plan that changed them. The apply finds the upstream’s plan as it does for a terraform_remote_state read, and on the commit’s first run a plan that changes nothing holds nothing. With no plan of the upstream to read, as in a project with no reports bucket, the reader’s wave waits whenever its plan changes something.
| Form | Read |
|---|---|
!terraform.state <component> <output> |
the output of the instance in the same stack |
!terraform.state <component> <stack> <output> |
the output of the instance in another stack |
An output as .name or .name.key |
that output, or a key inside it |
!terraform.output |
the same as !terraform.state |
!store, a read inside a map or a list, or a yq expression |
refused; output the value from an instance and read it whole |
Roles by stack
Section titled “Roles by stack”An instance’s root is <stack>/<component>, so oidc.roles globs give each stack its roles:
identity:
roles:
"dev/*": { plan: arn:aws:iam::111:role/dev-plan, apply: arn:aws:iam::111:role/dev-apply }
"prod/*": { plan: arn:aws:iam::222:role/prod-plan, apply: arn:aws:iam::222:role/prod-apply }terragucci config check lists each role with its stack’s instances and their state keys, and warns when an instance reads another stack’s state. A read uses the upstream’s role.
- Setting levels: how terragucci’s settings combine with the inheritance this tool already has.
- Approve a waiting wave
- Use Terragrunt, the same model for units
terragucciHelp setting it up: Intentius
These docs count page views and clicks with PostHog. They set no cookies, store nothing in your browser, and send nothing when your browser asks not to be tracked.