terragrunt
terragrunt copied to clipboard
Running terragrunt destroy on a single folder will evaluate all folders
Describe the bug
When running terragrunt destroy
(and likely other commands) on a folder it will needlessly recursively evaluate all upper level folders delaying the operation and sometimes entering a processing loop (didn't manage to create a simple case for that).
While not evident in the example this can add minutes to the run if the upper level folder has many folders with complex terragrunt.hcl
.
Steps To Reproduce
Run terragrunt destroy --terragrunt-log-level debug
on a single folder, terragrunt will evaluate the current folder then begin evaluating all folders a level above.
# deployment on each of the numbered folders in path folder/$number, module is just an empty main.tf
terraform {
source = "../../module"
}
include {
path = find_in_parent_folders()
expose = true
}
# base terragrunt.hcl
locals {}
Example code: terragrunt-bug.zip
tg/folder/one> terragrunt destroy --terragrunt-log-level debug
10:16:02.314 DEBUG Terragrunt Version: 0.69.9
10:16:02.314 DEBUG Did not find any locals block: skipping evaluation.
10:16:02.314 DEBUG Detected single bare include block - exposing as top level
10:16:02.314 DEBUG Found locals block: evaluating the expressions.
10:16:02.314 DEBUG Found locals block: evaluating the expressions.
10:16:02.315 DEBUG Found locals block: evaluating the expressions.
10:16:02.315 DEBUG [Partial] Included config ../../terragrunt.hcl has strategy shallow merge: merging config in (shallow).
10:16:02.315 DEBUG Running command: tofu --version
10:16:02.315 DEBUG Engine is not enabled, running command directly in .
10:16:02.333 DEBUG tofu version: 1.8.7
10:16:02.333 DEBUG Reading Terragrunt config file at ./terragrunt.hcl
10:16:02.334 DEBUG Did not find any locals block: skipping evaluation.
10:16:02.334 DEBUG Detected single bare include block - exposing as top level
10:16:02.334 DEBUG Found locals block: evaluating the expressions.
10:16:02.334 DEBUG Found locals block: evaluating the expressions.
10:16:02.334 DEBUG [Partial] Included config ../../terragrunt.hcl has strategy shallow merge: merging config in (shallow).
10:16:02.334 DEBUG Did not find any locals block: skipping evaluation.
10:16:02.335 DEBUG Detected single bare include block - exposing as top level
10:16:02.335 DEBUG Found locals block: evaluating the expressions.
10:16:02.335 DEBUG Found locals block: evaluating the expressions.
10:16:02.335 DEBUG Included config ../../terragrunt.hcl has strategy shallow merge: merging config in (shallow) for dependency.
10:16:02.335 DEBUG Detected single bare include block - exposing as top level
10:16:02.335 DEBUG Found locals block: evaluating the expressions.
10:16:02.337 DEBUG Found locals block: evaluating the expressions.
10:16:02.337 DEBUG Included config ../../terragrunt.hcl has strategy shallow merge: merging config in (shallow).
10:16:02.338 DEBUG tofu files in ../../../../../.cache/terragrunt/downloads/IgLK4KSTuNK_msXDl0gRsqsH7Zc/LQsymLGlJTaFUPqoAlb9T_RGCWM are up to date. Will not download again.
10:16:02.338 DEBUG Copying files from . into ../../../../../.cache/terragrunt/downloads/IgLK4KSTuNK_msXDl0gRsqsH7Zc/LQsymLGlJTaFUPqoAlb9T_RGCWM
10:16:02.338 DEBUG Setting working directory to ../../../../../.cache/terragrunt/downloads/IgLK4KSTuNK_msXDl0gRsqsH7Zc/LQsymLGlJTaFUPqoAlb9T_RGCWM
10:16:02.339 DEBUG Running command: git rev-parse --show-toplevel
10:16:02.339 DEBUG Command output will be suppressed.
10:16:02.342 DEBUG [../..] Found locals block: evaluating the expressions.
10:16:02.342 DEBUG [../..] Setting download directory for module . to ../../.terragrunt-cache
10:16:02.342 DEBUG Module ../.. does not have an associated terraform configuration and will be skipped.
10:16:02.342 DEBUG [../eight] Did not find any locals block: skipping evaluation.
10:16:02.342 DEBUG [../eight] Detected single bare include block - exposing as top level
10:16:02.342 DEBUG [../eight] Found locals block: evaluating the expressions.
10:16:02.343 DEBUG [../eight] Found locals block: evaluating the expressions.
10:16:02.343 DEBUG [../eight] [Partial] Included config ../../terragrunt.hcl has strategy shallow merge: merging config in (shallow).
10:16:02.343 DEBUG [../eight] Setting download directory for module ../eight to ../eight/.terragrunt-cache
10:16:02.343 DEBUG [../five] Did not find any locals block: skipping evaluation.
10:16:02.343 DEBUG [../five] Detected single bare include block - exposing as top level
10:16:02.344 DEBUG [../five] Found locals block: evaluating the expressions.
10:16:02.344 DEBUG [../five] Found locals block: evaluating the expressions.
10:16:02.344 DEBUG [../five] [Partial] Included config ../../terragrunt.hcl has strategy shallow merge: merging config in (shallow).
10:16:02.344 DEBUG [../five] Setting download directory for module ../five to ../five/.terragrunt-cache
10:16:02.344 DEBUG [../four] Did not find any locals block: skipping evaluation.
10:16:02.344 DEBUG [../four] Detected single bare include block - exposing as top level
10:16:02.345 DEBUG [../four] Found locals block: evaluating the expressions.
10:16:02.345 DEBUG [../four] Found locals block: evaluating the expressions.
10:16:02.345 DEBUG [../four] [Partial] Included config ../../terragrunt.hcl has strategy shallow merge: merging config in (shallow).
10:16:02.345 DEBUG [../four] Setting download directory for module ../four to ../four/.terragrunt-cache
10:16:02.346 DEBUG [../nine] Did not find any locals block: skipping evaluation.
10:16:02.346 DEBUG [../nine] Detected single bare include block - exposing as top level
10:16:02.346 DEBUG [../nine] Found locals block: evaluating the expressions.
10:16:02.346 DEBUG [../nine] Found locals block: evaluating the expressions.
10:16:02.346 DEBUG [../nine] [Partial] Included config ../../terragrunt.hcl has strategy shallow merge: merging config in (shallow).
10:16:02.347 DEBUG [../nine] Setting download directory for module ../nine to ../nine/.terragrunt-cache
10:16:02.347 DEBUG Did not find any locals block: skipping evaluation.
10:16:02.347 DEBUG Detected single bare include block - exposing as top level
10:16:02.347 DEBUG Found locals block: evaluating the expressions.
10:16:02.347 DEBUG Found locals block: evaluating the expressions.
10:16:02.347 DEBUG [Partial] Included config ../../terragrunt.hcl has strategy shallow merge: merging config in (shallow).
10:16:02.347 DEBUG Setting download directory for module . to ./.terragrunt-cache
10:16:02.348 DEBUG [../seven] Did not find any locals block: skipping evaluation.
10:16:02.348 DEBUG [../seven] Detected single bare include block - exposing as top level
10:16:02.348 DEBUG [../seven] Found locals block: evaluating the expressions.
10:16:02.349 DEBUG [../seven] Found locals block: evaluating the expressions.
10:16:02.349 DEBUG [../seven] [Partial] Included config ../../terragrunt.hcl has strategy shallow merge: merging config in (shallow).
10:16:02.349 DEBUG [../seven] Setting download directory for module ../seven to ../seven/.terragrunt-cache
10:16:02.350 DEBUG [../six] Did not find any locals block: skipping evaluation.
10:16:02.350 DEBUG [../six] Detected single bare include block - exposing as top level
10:16:02.350 DEBUG [../six] Found locals block: evaluating the expressions.
10:16:02.351 DEBUG [../six] Found locals block: evaluating the expressions.
10:16:02.352 DEBUG [../six] [Partial] Included config ../../terragrunt.hcl has strategy shallow merge: merging config in (shallow).
10:16:02.352 DEBUG [../six] Setting download directory for module ../six to ../six/.terragrunt-cache
10:16:02.353 DEBUG [../ten] Did not find any locals block: skipping evaluation.
10:16:02.353 DEBUG [../ten] Detected single bare include block - exposing as top level
10:16:02.353 DEBUG [../ten] Found locals block: evaluating the expressions.
10:16:02.353 DEBUG [../ten] Found locals block: evaluating the expressions.
10:16:02.353 DEBUG [../ten] [Partial] Included config ../../terragrunt.hcl has strategy shallow merge: merging config in (shallow).
10:16:02.353 DEBUG [../ten] Setting download directory for module ../ten to ../ten/.terragrunt-cache
10:16:02.354 DEBUG [../tree] Did not find any locals block: skipping evaluation.
10:16:02.355 DEBUG [../tree] Detected single bare include block - exposing as top level
10:16:02.355 DEBUG [../tree] Found locals block: evaluating the expressions.
10:16:02.356 DEBUG [../tree] Found locals block: evaluating the expressions.
10:16:02.356 DEBUG [../tree] [Partial] Included config ../../terragrunt.hcl has strategy shallow merge: merging config in (shallow).
10:16:02.356 DEBUG [../tree] Setting download directory for module ../tree to ../tree/.terragrunt-cache
10:16:02.356 DEBUG [../two] Did not find any locals block: skipping evaluation.
10:16:02.357 DEBUG [../two] Detected single bare include block - exposing as top level
10:16:02.357 DEBUG [../two] Found locals block: evaluating the expressions.
10:16:02.358 DEBUG [../two] Found locals block: evaluating the expressions.
10:16:02.358 DEBUG [../two] [Partial] Included config ../../terragrunt.hcl has strategy shallow merge: merging config in (shallow).
10:16:02.358 DEBUG [../two] Setting download directory for module ../two to ../two/.terragrunt-cache
10:16:02.358 DEBUG Running command: tofu init
10:16:02.358 DEBUG Engine is not enabled, running command directly in ../../../../../.cache/terragrunt/downloads/IgLK4KSTuNK_msXDl0gRsqsH7Zc/LQsymLGlJTaFUPqoAlb9T_RGCWM
10:16:02.376 DEBUG tofu: Initializing the backend...
10:16:02.377 DEBUG tofu: Initializing provider plugins...
10:16:02.377 DEBUG tofu: OpenTofu has been successfully initialized!
10:16:02.377 DEBUG tofu:
10:16:02.377 DEBUG tofu: You may now begin working with OpenTofu. Try running "tofu plan" to see
10:16:02.377 DEBUG tofu: any changes that are required for your infrastructure. All OpenTofu commands
10:16:02.377 DEBUG tofu: should now work.
10:16:02.377 DEBUG tofu: If you ever set or change modules or backend configuration for OpenTofu,
10:16:02.377 DEBUG tofu: rerun this command to reinitialize your working directory. If you forget, other
10:16:02.377 DEBUG tofu: commands will detect it and remind you to do so if necessary.
10:16:02.378 DEBUG Copying lock file from ../../../../../.cache/terragrunt/downloads/IgLK4KSTuNK_msXDl0gRsqsH7Zc/LQsymLGlJTaFUPqoAlb9T_RGCWM/.terraform.lock.hcl to .
10:16:02.379 DEBUG Running command: tofu destroy
10:16:02.379 DEBUG Engine is not enabled, running command directly in ../../../../../.cache/terragrunt/downloads/IgLK4KSTuNK_msXDl0gRsqsH7Zc/LQsymLGlJTaFUPqoAlb9T_RGCWM
10:16:02.397 DEBUG tofu: No changes. No objects need to be destroyed.
10:16:02.397 DEBUG tofu: Either you have not created any objects yet or the existing objects were
10:16:02.397 DEBUG tofu: already deleted outside of OpenTofu.
10:16:02.400 DEBUG tofu:
10:16:02.400 DEBUG tofu: Destroy complete! Resources: 0 destroyed.
10:16:02.400 DEBUG tofu:
Expected behavior
terragrunt would evaluate just the current folder (one) and not evaluate all the folders in the directory above it.
Nice to haves
- [x] Terminal output
- [ ] Screenshots
Versions
- Terragrunt version: 0.69.0
- OpenTofu version: 1.8.6
- Environment details: WSL2 Ubuntu 24.04
Additional context
Add any other context about the problem here.