Fix failed deployments or reconcile drift by rerunning stacks with Terramate Triggers β
Stack Triggers let you explicitly control Terramate Change Detection by marking stacks as changed even when the stackβs code did not change.
A trigger marks a stack as changed even though no direct or indirect code changes have been made to it.
When to use β
- A deployment failed after merging a pull request. The affected stacks are in a failed state. Sometimes a fix requires code changes; often you only need to rerun the deployment with the same code. In both cases, create a new pull request and trigger the failed stacks to generate a fresh preview and diagnose faster.
- Drift is detected and should be reconciled by applying the current code without changing it. Trigger the drifted stacks and create a pull request to fix the drift.
Prerequisites β
- Terramate CLI or Terramate Catalyst is installed
- A repository with one or more stacks under version control (Git)
1. Create a new branch β
bash
git checkout -b my-branch2. Mark a stack as changed β
bash
terramate trigger /path/to/stack
git add .tmtriggers
git commit -m "trigger a stack"3. Trigger by Cloud status (optional) β
bash
# All drifted stacks
terramate trigger --status=drifted
git add .tmtriggers
git commit -m "trigger drifted stacks"Supported stack status codes include:
healthy(meta status matching Terramate Cloud UI)okβ Stacks that are neither drifted nor have failed (unfixed) deployments
unhealthy(meta status matching Terramate Cloud UI)failedβ Stacks with a failed latest deployment that hasnβt been fixed yet (may also be drifted; failed takes precedence)driftedβ Stacks that are drifted without a previously failed deployment
Additional, more detailed codes are available via --deployment-status or --drift-status.
4. Trigger nested stacks (optional) β
bash
terramate trigger /path/to/parent --recursive
git add .tmtriggers
git commit -m "trigger nested stacks recursively"5. Preview the changes β
Create a Terraform preview (plan) of all triggered or changed stacks:
bash
terramate run --changed -- terraform planResult β
- The plan includes stacks with actual code/config changes and any stacks you explicitly marked (change triggers) or selected by status.
- In normal pullβrequest workflows, these triggered stacks are considered even if no stack code changed; they are added in addition to any stacks that change detection would include normally.
Troubleshooting β
- No stacks selected: ensure
.tmtriggersfiles were added and committed; verify the stack path is correct. - Status filter returns none: confirm the stack status in Terramate Cloud and that you used the correct
--status,--deployment-status, or--drift-status. - Unexpected set of stacks: remember the comparison base differs on default vs feature branches; override with
--git-change-base=<commit|branch|tag>. - Nested stacks not affected: use
--recursivewith the correct parent path.
Notes β
- Trigger files are stored in the
.tmtriggers/directory at the repository root. They must be checked in to be considered by change detection. Do NOT add this directory to.gitignore. - Trigger files can be deleted at any time with no effect on past runs. If a trigger is introduced in one commit and removed in a later commit within the same changeset, it has no effect because Terramate considers the full changeset, not individual commits.
- Terramate supports different trigger types. This article focuses on
changetriggers.ignoretriggers can exclude stacks from change detection (e.g., trivial or purely global changes).
Related guides and references β
- Reference:Β terramate trigger
- Concepts:Β Change Detection