Open
Description
Describe the bug
Calling get_working_dir()
causes terragrunt to crash when in an included terragrunt.hcl
.
Steps To Reproduce
- Have a global
global.hcl
file like this.
locals {
working_dir = get_working_dir()
}
- Include it from a child
terragrunt.hcl
.
include "test" {
path = find_in_parent_folders("global.hcl")
expose = true
}
Expected behavior
No crash.
Nice to haves
terragrunt init --terragrunt-log-level debug
08:51:44.180 DEBUG Terragrunt Version: 0.69.1
08:51:44.181 DEBUG Did not find any locals block: skipping evaluation.
08:51:44.194 DEBUG Found locals block: evaluating the expressions.
08:51:44.194 DEBUG Running command: pf-get-repo-variables
08:51:44.194 DEBUG Command output will be suppressed.
08:51:44.306 DEBUG run_cmd output: [REDACTED]
08:51:44.307 DEBUG Start processing get_working_dir built-in function
08:51:44.308 DEBUG Did not find any locals block: skipping evaluation.
08:51:44.319 DEBUG Found locals block: evaluating the expressions.
08:51:44.319 DEBUG run_cmd, cached output: [REDACTED]
08:51:44.320 DEBUG Evaluated 15 locals (remaining 50): local_dev_namespace, is_ci, pf_stack_repo, region_raw_vars, environment_raw_vars, lockfile_contents, repo_vars, working_dir, module_raw_vars, global_raw_vars, region_user_vars, module_user_vars, global_user_vars, environment_user_vars, provider_folder
08:51:44.320 DEBUG Evaluated 19 locals (remaining 31): repo_name, region_vars, enable_vault, enable_pf, enable_tls, global_vars, enable_local, enable_authentik, primary_branch, iac_dir, enable_helm, repo_root, enable_aws, enable_time, enable_random, repo_url, enable_kubernetes, environment_vars, module_vars
08:51:44.321 DEBUG Evaluated 9 locals (remaining 22): vars, region_extra_inputs, global_extra_tags, module_extra_tags, global_extra_inputs, environment_extra_tags, region_extra_tags, module_extra_inputs, environment_extra_inputs
08:51:44.323 DEBUG git show-toplevel result:
../../../../../..
08:51:44.323 DEBUG Evaluated 11 locals (remaining 11): kube_config_context, version, is_local, extra_tags, vault_address, module, extra_inputs, pf_stack_version, pf_stack_local_use_relative, kube_api_server, pf_stack_local_absolute_path
08:51:44.323 DEBUG Running command: pf-get-vault-token --address https://vault.prod.panfactum.com
08:51:44.323 DEBUG Command output will be suppressed.
08:51:44.594 DEBUG run_cmd output: [REDACTED]
08:51:44.594 DEBUG Running command: realpath --relative-to= ../../../../../..
08:51:44.594 DEBUG Command output will be suppressed.
realpath: '': No such file or directory
08:51:44.595 ERROR Error: Error in function call
08:51:44.595 ERROR on ../../../panfactum.hcl line 76, in locals:
08:51:44.595 ERROR 76: pf_stack_local_relative_path_from_working_dir = run_cmd("--terragrunt-global-cache", "--terragrunt-quiet", "realpath", "--relative-to=${local.working_dir}", local.pf_stack_local_absolute_path) # The relative path from the directory where tf will be run to the local copy of the Panfactum stack
08:51:44.596 ERROR
08:51:44.596 ERROR with
08:51:44.596 ERROR local.pf_stack_local_absolute_path as "../../../../../.."
08:51:44.596 ERROR ,
08:51:44.596 ERROR
08:51:44.596 ERROR local.working_dir as ""
08:51:44.596 ERROR .
08:51:44.596 ERROR Call to function "run_cmd" failed: Failed to execute "realpath --relative-to= ../../../../../.." in
.
realpath: '': No such file or directory
exit status 1.
08:51:44.596 DEBUG Encountered error while evaluating locals in file ./terragrunt.hcl
08:51:44.596 DEBUG Complete processing get_working_dir built-in function
08:51:44.596 ERROR Error: Error in function call
08:51:44.596 ERROR on ../../../panfactum.hcl line 69, in locals:
08:51:44.596 ERROR 69: working_dir = get_working_dir()
08:51:44.597 ERROR
08:51:44.597 ERROR Call to function "get_working_dir" failed: ../../../panfactum.hcl:76,51-59: Error in function call; Call to function
"run_cmd" failed: Failed to execute "realpath --relative-to= ../../../../../.." in
.
realpath: '': No such file or directory
exit status 1..
08:51:44.597 DEBUG Encountered error while evaluating locals in file ./terragrunt.hcl
08:51:44.597 ERROR ../../../panfactum.hcl:69,17-33: Error in function call; Call to function "get_working_dir" failed: ../../../panfactum.hcl:76,51-59: Error in function call; Call to function "run_cmd" failed: Failed to execute "realpath --relative-to= ../../../../../.." in .
realpath: '': No such file or directory
exit status 1..
08:51:44.597 DEBUG hcl.Diagnostics ../../../panfactum.hcl:69,17-33: Error in function call; Call to function "get_working_dir" failed: ../../../panfactum.hcl:76,51-59: Error in function call; Call to function "run_cmd" failed: Failed to execute "realpath --relative-to= ../../../../../.." in .
realpath: '': No such file or directory
exit status 1..
github.com/gruntwork-io/terragrunt/config/hclparse/attributes.go:80 (0x16d2846)
github.com/gruntwork-io/terragrunt/config/locals.go:131 (0x1abbfda)
github.com/gruntwork-io/terragrunt/config/locals.go:58 (0x1abb806)
github.com/gruntwork-io/terragrunt/config/config_partial.go:171 (0x1aa6749)
github.com/gruntwork-io/terragrunt/config/config_partial.go:331 (0x1aa756c)
github.com/gruntwork-io/terragrunt/config/config_partial.go:286 (0x1aa73be)
github.com/gruntwork-io/terragrunt/config/config.go:931 (0x1a94c3d)
github.com/gruntwork-io/terragrunt/config/config.go:847 (0x1a9450c)
github.com/gruntwork-io/terragrunt/config/config.go:787 (0x1a942b8)
github.com/gruntwork-io/terragrunt/telemetry/metrics.go:42 (0xb3af33)
github.com/gruntwork-io/terragrunt/telemetry/telemetry.go:80 (0x1a93ead)
github.com/gruntwork-io/terragrunt/telemetry/traces.go:38 (0xb3d92f)
github.com/gruntwork-io/terragrunt/telemetry/telemetry.go:79 (0x1a93e25)
github.com/gruntwork-io/terragrunt/config/config.go:744 (0x1a93bf3)
github.com/gruntwork-io/terragrunt/config/include.go:95 (0x1ab5705)
github.com/gruntwork-io/terragrunt/config/cty_helpers.go:330 (0x1aaa4dc)
github.com/gruntwork-io/terragrunt/config/cty_helpers.go:309 (0x1aaa1ef)
github.com/gruntwork-io/terragrunt/config/config_helpers.go:214 (0x1a9f96e)
github.com/gruntwork-io/terragrunt/config/config_partial.go:348 (0x1aa77b9)
github.com/gruntwork-io/terragrunt/config/config_partial.go:286 (0x1aa73be)
github.com/gruntwork-io/terragrunt/config/config_partial.go:264 (0x1aa6f9f)
github.com/gruntwork-io/terragrunt/cli/commands/terraform/version_check.go:42 (0x1c0d87e)
github.com/gruntwork-io/terragrunt/cli/commands/terraform/action.go:97 (0x1c044a6)
github.com/gruntwork-io/terragrunt/cli/commands/terraform/action.go:83 (0x1c04332)
github.com/gruntwork-io/terragrunt/cli/commands/terraform/command.go:47 (0x2059c0a)
github.com/gruntwork-io/terragrunt/cli/app.go:233 (0x205b5a7)
golang.org/x/sync@v0.9.0/errgroup/errgroup.go:78 (0x1580eb0)
runtime/asm_amd64.s:1700 (0x479ee1)
08:51:44.598 ERROR Unable to determine underlying exit code, so Terragrunt will exit with error code 1
Versions
- Terragrunt version: v0.69.1
- OpenTofu/Terraform version: N/A
- Environment details (Ubuntu 20.04, Windows 10, etc.): Linux
Additional context
get_working_dir()
CAN be run without crashes only if used in a non-included file.
Activity