Skip to content

Use Terramate

llms.txtlists every page for an agent
Optional: hand this page to your coding agentThe steps work by hand too.
Show the whole prompt
Read https://intentius.io/terragucci/guides/use-terramate/.
Run `npx terragucci init --dry-run --json`, list the stacks and waves it found,
tell me about anything 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`.

A pipeline whose roots are your Terramate stacks, applied in the order Terramate gives them, a layer at a time behind the same gate as plain roots.

Terramate and Terramate Cloud already do part of this work:

Feature What it does
Orchestration terramate run runs parent stacks before their children, in the order after and before set, in parallel with --parallel
Change detection --changed limits a run to the stacks git shows changed, including those whose local modules changed
CI/CD workflows preview, deployment and drift check workflows for GitHub Actions, GitLab CI and Bitbucket Pipelines
Deployments (Terramate Cloud) a searchable history of every deployment, with alerts when one fails
Drift management (Terramate Cloud) drift checks after a deployment and on a schedule, with alerts and reconciliation jobs in your CI

If ordered runs of the changed stacks and Terramate’s own workflows already fit your team, you may not need terragucci’s waves.

  • Each layer waits at its own gate. An approval binds the wave’s plan digest and counts only from someone with no hand in the change.
  • A wave whose plans moved since the approval applies nothing.
  • A stack that reads an input is never planned on its mock; it waits for its upstream’s state (Outputs sharing).
  • init writes the pipeline for Forgejo as well as GitHub and GitLab.
You need Why
terramate.tm.hcl at the repo root, or a stack.tm.hcl below it init detects Terramate from it
Terramate on the path, or TERRAGUCCI_TERRAMATE naming it init runs terramate list and terramate experimental run-graph
Generated code committed and up to date the jobs plan what git holds
A remote backend for each stack, such as s3 each job starts from a fresh checkout
terragucci installed (Get your first plan note) init writes the pipeline
  1. Run init.

    Terminal window
    npx terragucci init --dry-run

    It prints the stacks and how many waves they make:

    found Terramate (terramate.tm.hcl): 3 stacks in 2 waves from terramate list and the stacks' order, ...
  2. Write the pipeline.

    Terminal window
    npx terragucci init

    Commit it and open a pull request.

What How
A root a stack terramate list names that holds Terraform, by its directory, such as stacks/app
A stack with no Terraform not a root; the order through it is kept
Leaving a stack out a .tmskip file in its directory, as Terramate reads it
roots and synth refused: Terramate decides the stacks
stack {
id = "app"
after = ["tag:net"]
}
What How
Order after and before, with stack paths, directories and tag: filters, as terramate experimental run-graph resolves them
Nesting a parent stack runs before the stacks under it
An input block puts the stack after the one it reads
terraform_remote_state between stacks puts the reader after the stack it reads, as for plain roots
Each wave one layer, in its own apply job behind its own gate
A path in after or before that names no stack, or a cycle init stops and names it; Terramate only warns about the path
waves.canary the canary stacks’ layers go first

Every job installs Terramate 0.17.3, checked against the release’s checksums.txt, then runs terragucci terramate generate before it reads the stacks:

Step
terramate generate --detailed-exit-code when it would change a file, the job fails, naming the file; run terramate generate and commit, as terramate run asks too
Edges each stack’s order and inputs, written to .terragucci-terramate.json beside it in the job

A pull request plans the stacks its diff touches, and every stack that runs after one of them. Roots a change plans compares this with the other repo shapes.

A pull request that changes Plans
stacks/network stacks/network, then stacks/app, whose after = ["tag:net"] matches it
a global in terramate.tm.hcl, with the generated code every stack whose generated files changed, and the stacks after them
a global, without the generated code nothing: the check fails on the stale code

An input block reads another stack’s output:

input "net_name" {
backend = "default"
from_stack_id = "network"
value = outputs.name.value
}

The job reads the upstream’s outputs from its state, once it has a cloud credential, and fills the variable Terramate generated. While the upstream has no state, the stack is held back rather than planned on its mock, and the plan note says which stack it waits for. The sharing_backend command is not run; the stack’s own binary reads the state.

A pull request reads the upstream’s applied state, never its plan. When one change edits both stacks, 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.

value Read
outputs.<name>.value that output
outputs.<name>.value.key or ["key"] a key inside it
Anything else, such as a function call refused; read the upstream with a terraform_remote_state data source
A from_stack_id no stack has refused

Terramate’s watch files, scripts, wants and wanted_by, and Terramate Cloud. terragucci’s own affected selection and hooks run instead. A drift pull request, rollouts and generate are refused, since their edits would land in code terramate generate owns; respond.drift: attribute names who changed each value in the drift issue.

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.