Skip to content

get_terraform_command

unitstack

Usage

get_terraform_command() --> string

get_terraform_command returns the OpenTofu/Terraform command Terragrunt is running. For apply -destroy, it returns destroy. Under a Terragrunt command that doesn’t run OpenTofu/Terraform, it returns that command’s name, e.g. render.

terragrunt.hcl
locals {
destroying = get_terraform_command() == "destroy"
}
inputs = {
deletion_protection = !local.destroying
}

For the arguments too, use get_terraform_cli_args.

Examples

During terragrunt run -- plan.

terragrunt.hcl
inputs = {
command = get_terraform_command() # "plan"
}