Skip to main content

Use tfcmt with terragrunt run-all


Terragrunt is a thin wrapper that provides extra tools for keeping your configurations DRY, working with multiple Terraform modules, and managing remote state.

Terragrunt supports deploying multiple Terraform modules in a single command by terragrunt run-all command, but tfcmt doesn't support the output.

❌ This doesn't work.

$ tfcmt plan -- terragrunt run-all plan

You can solve the issue by Terragrunt's --terragrunt-tfpath option.

  1. Create a wrapper script of terraform and make it executable
$ vi
$ chmod a+x


set -euo pipefail


base_dir=$(git rev-parse --show-toplevel) # Please fix if necessary

if [ "$command" == "plan" ]; then
tfcmt -var "target:${target}" plan -- terraform "$@"
elif [ "$command" == "apply" ]; then
tfcmt -var "target:${target}" apply -- terraform "$@"
terraform "$@"
  1. Run terragrunt run-all with --terragrunt-tfpath
$ terragrunt run-all plan --terragrunt-tfpath "<absolute path of>"

Then the result of terraform plan is posted per module.