Script Run
Note: This is an upcoming experimental feature that is subject to change in the future. To use it now, you must enable the project config option terramate.config.experiments = ["scripts"]
The terramate script run
command will run a Terramate script over a set of stacks. CMD
needs to exactly match the label defined in the script
block. For example:
script "mycommand" {
...
}
The above script could therefore be run with script run mycommand
.
The script will run on all stacks under the current working directory where:
- the script is available (scripts follow the same inheritance rules as globals)
- any filters match.
script run
currently supports--changed
and--tags
filters.
It's also possible to define commands that consist of multiple keywords to create a multi-level command structure, i.e. command subcommand ...
:
script "command" "subcommand" {
...
}
The above can be run with script run command subcommand
.
If the experimental deployment targets option is enabled, --target
is required (see run).
Usage
terramate script run [options] CMD...
Examples
Run a script called "deploy" on all stacks where it is available:
terramate script run deploy
Run a script called "deploy" on all changed stacks where it is available:
terramate script run --changed deploy
Run a script called "deploy" on all changed stacks (not considering uncommitted files):
terramate script run --changed --disable-change-detection=git-uncommitted deploy
Run a script called "deploy" on all changed stacks and continue on error:
terramate script run --changed --continue-on-error deploy
Do a dry run of running the deploy script:
terramate script run --dry-run deploy
Run a script called "deploy" in a specific stack without recursing into subdirectories:
terramate -C path/to/stack script run --no-recursive deploy
Run a script in all stacks with an specific Terramate Cloud status:
terramate script run --status=unhealthy deploy
Run a script called "destroy" on all stacks in the reverse order:
terramate script run --reverse destroy