Script Run
Note
This is an experimental feature that might be subject to change in the future. To use it now, you must enable the project config option terramate.config.experiments = ["scripts"]
Overview
A script is a collection of different commands which are part of a workflow. You can run a single script run command to run all the commands of the script block as one single executable unit without having to run them one by one.
Usage
terramate script run [options] CMD...
CMD needs to match the label defined in the script block. For example:
script "mycommand" {
...
}The above script can be run with script run mycommand.
Scripts follow the same inheritance rules as globals and will only run where:
- The script is defined or inherited.
- The specified filters (
--changed,--tags, etc.) match.
Options
--changedRuns the script on stacks with changes.--tags=tagsRuns the script on stacks with specific tags.--disable-change-detection=modeDisables change detection for uncommitted files or other modes.--continue-on-errorContinues executing the script even if errors occur.--dry-runShows what would happen without executing the script.--no-recursiveRuns the script only in the current stack without traversing subdirectories.--status=statusFilters stacks based on Terramate Cloud status (e.g.,unhealthy).--reverseRuns the script in reverse order across stacks.
Examples
Run a script called deploy on all stacks where it is available:
terramate script run deployRun the deploy script on all changed stacks:
terramate script run --changed deployRun the deploy script on all changed stacks, ignoring uncommitted files:
terramate script run --changed --disable-change-detection=git-uncommitted deployRun the deploy script on all changed stacks and continue on error:
terramate script run --changed --continue-on-error deployPerform a dry run of the deploy script:
terramate script run --dry-run deployRun the deploy script in a specific stack without recursing into subdirectories:
terramate -C path/to/stack script run --no-recursive deployRun a script in all stacks with a specific Terramate Cloud status (unhealthy):
terramate script run --status=unhealthy deployRun the destroy script on all stacks in reverse order:
terramate script run --reverse destroy