Skip to content

Promote a release through environments

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/promote-a-release/.
Read terragucci.yml, chant.config.ts and terragucci.component.ts in this repo, and tell me the promotion order, the root each component applies in each environment, and which environments wait for an approval.
Read only: do not run terragucci promote, terragucci rollback or chant release cut.
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 release holds the files of one commit for each environment. It moves through the environments in the order promotion lists. Staging gets the staging roots’ files only, never dev’s. A person approves each release once for an environment with a gate. terragucci rollback puts an earlier release back in one environment, behind the same gate.

chant/lifecycle records each deploy with the release, the person who ran it and the approver.

You need Why
A repo of plain roots, with one root per environment for each part, such as envs/dev/network and envs/prod/network each environment applies its own roots. Terragrunt units and Atmos instances are not deployed this way
environments naming each environment’s roots promotion lists environments by name
A backend that is not local for each root a release deploys a recorded copy of the root’s files, which reads its state from the backend
@intentius/chant-lexicon-terraform installed beside terragucci, at the version terragucci promote names when it finds none a deploy applies each root with the terraform lexicon’s terraform-apply step
  1. Set the order in terragucci.yml:

    environments:
    dev: { roots: ["envs/dev/**"], gate: never }
    staging: { roots: ["envs/staging/**"], gate: always }
    prod: { roots: ["envs/prod/**"], gate: always }
    promotion: [dev, staging, prod]

    Run npx terragucci init and commit what it writes. chant.config.ts lists the environments in that order, terragucci.component.ts holds each root as a component (The components), and .chant/pipeline.ts has one stage per environment. After a change to terragucci.yml, npx terragucci ci writes the pipeline again.

    From then on, each merge applies dev and then cuts a release of the merge commit, labelled with the next version; the apply job’s log names it.

    chant.config.ts also sets release: { green: "forge-checks" }. The cut’s green gate is then the merge commit’s checks on the forge, among them the check job and the earlier wave jobs of the run that applies: it waits while they run and cuts once they pass, reading them with the apply job’s forge token, so the repository needs no ci/green tag. On GitHub the apply jobs get read access to checks, statuses and actions for it. When chant.config.ts is the repo’s own, init names the line to add. Steps 2 and 3 are for release: { cut: false }, or a release of another commit.

  2. Cut a release from a commit of the default branch whose checks passed, in a clean checkout of that commit:

    Terminal window
    GH_TOKEN=$(gh auth token) npx chant release cut v1.4.0 --yes
    git push origin release/v1.4.0

    The cut records each environment’s roots as they are at that commit. Without --yes it prints what it would record and records nothing.

  3. Deploy the release to the first environment:

    Terminal window
    npx chant run --components all --env dev --release v1.4.0
  4. Promote it to the next environment:

    Terminal window
    npx terragucci promote --to staging --release v1.4.0 --dry-run
    npx terragucci promote --to staging --release v1.4.0

    --dry-run prints the plan and changes nothing. Under a gate, the promote stops at the staging stage and exits 3:

    error: tf-apply staging waits for an approval of jcs1-sha256:fc692c3f… [pipeline-gate-waiting]
    Approve it with: terragucci approve release staging
  5. A reviewer approves the release for staging. Then the same promote applies:

    Terminal window
    npx terragucci approve release staging
    npx terragucci promote --to staging --release v1.4.0

    The approval holds for that release in staging, and the promote spends it. Nothing else waits, so the promote applies straight after it.

  6. Repeat for prod. A promote that skips an environment, such as --to prod while staging has not run the release, is refused; --allow-skip lets it through.

Terminal window
npx terragucci rollback prod --release v1.3.0 --dry-run
npx terragucci rollback prod --release v1.3.0

prod gets the files v1.3.0 recorded for it. The rollback waits for one approval like a promote: approve it with terragucci approve release prod and run the same rollback again. The deploy record then names v1.3.0 as the version prod runs. With pause_after_rollback on prod, the rollback then pauses the stage until terragucci resume prod.

init names each root’s component by its path with the segment that names its environment taken out: envs/dev/network and envs/prod/network are both envs-network. A promote to staging takes envs-network as dev recorded it and applies envs/staging/network. A root whose path has no segment named for its environment keeps its whole path as its name, and init says so when a later environment has a component the one before it lacks.

An environment waits for one approval unless its gate is never. With no gate of its own, it takes the top-level gate. That approval belongs to the environment’s stage in .chant/pipeline.ts. init writes the pipeline and the components from one terragucci.yml, so they agree on which environments wait. A promote asks before it plans, so on-destructive asks on every promote.

A promote or rollback reads .chant/pipeline.ts on the default branch first, as chant does, so push the pipeline with the components. When .chant/pipeline.ts is the repo’s own, init keeps it and adds a gate step to the components for each environment that waits.

The pipeline a merge runs is the same with or without promotion: it applies what a pull request changed in every environment. To have staging and prod change only through a promote, route their roots to a branch nobody pushes with apply.branches, so a merge applies dev alone:

apply:
branches:
release: ["envs/staging/**", "envs/prod/**"]

terragucci promote lists every flag.

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.