terragrunt
terragrunt copied to clipboard
`run_cmd` is executed twice
it seems that run_cmd
is executed twice.
terragrunt.hcl:
include {
path = find_in_parent_folders("terragrunt.hcl")
}
locals {
common_vars = read_terragrunt_config(find_in_parent_folders("terragrunt.hcl"))
}
Parent terragrunt.hcl:
locals {
test = run_cmd("python", "get_bucket.py", "production")
}
Output:
$ terragrunt init
my-production-backend-bucket
my-production-backend-bucket
ERRO[0000] Did not find any Terraform files (*.tf) in /Documents/terragrunt/test
ERRO[0000] Unable to determine underlying exit code, so Terragrunt will exit with error code 1
Expected behavior:
$ terragrunt init
my-production-backend-bucket
ERRO[0000] Did not find any Terraform files (*.tf) in /Documents/terragrunt/test
ERRO[0000] Unable to determine underlying exit code, so Terragrunt will exit with error code 1
I think it is executed twice because run_cmd
is invoked in different directories, and result is cached for "command + directory"
terragrunt.hcl:
include {
path = find_in_parent_folders("terragrunt.hcl")
}
locals {
common_vars = read_terragrunt_config(find_in_parent_folders("terragrunt.hcl"))
common_vars2 = read_terragrunt_config(find_in_parent_folders("terragrunt.hcl"))
}
Parent terragrunt.hcl:
locals {
test = run_cmd("pwd")
}
Execution:
$ terragrunt init
/tmp/run_cmd
/tmp/run_cmd/app
...
was printed only once "/tmp/run_cmd/app" even in locals was included terragrunt.hcl
twice
This also happens if you have a dependency or dependencies block in the included terragrunt.hcl file