-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When using include to import exclude blocks from a parent configuration, the exclusion rules are ignored for single unit runs but work correctly for --all runs.
Steps To Reproduce
The issue can be reproduced with this minimal setup:
Directory structure
.
├── module
│ └── main.tf
├── root.hcl
└── unit
└── terragrunt.hclFile contents
root.hcl
# Example to exclude all units from running
exclude {
if = true # Boolean to determine exclusion.
no_run = true # Boolean to prevent the unit from running (even when not using `--all`).
actions = ["all"] # List of actions to exclude (e.g., "plan", "apply", "all", "all_except_output").
exclude_dependencies = true # Boolean to determine if dependencies should also be excluded.
}unit/terragrunt.hcl
# Include all settings from root.hcl
include "root" {
path = find_in_parent_folders("root.hcl")
}
# Use example module
terraform {
source = "../module"
}
inputs = {}module/main.tf
output "example_output" {
value = "hello world"
}Reproduction commands
# Switch to unit directory
$ cd unit/
# This should be excluded (not working as expected)
$ terragrunt run -- plan
Initializing the backend...
Initializing provider plugins...
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
Changes to Outputs:
+ example_output = "hello world"
You can apply this plan to save these new output values to the Terraform
state, without changing any real infrastructure.
─────────────────────────────────────────────────────────────────────────────
Note: You didn't use the -out option to save this plan, so Terraform can't
guarantee to take exactly these actions if you run "terraform apply" now.
# works as expected
$ terragrunt run --all -- plan
❯❯ Run Summary 1 units 292ns
────────────────────────────
Excluded 1
When I change the content of unit/terragrunt.hcl to include the exclude block directly:
# Include all settings from root.hcl
include "root" {
path = find_in_parent_folders("root.hcl")
}
# Example to exclude all units from running
exclude {
if = true # Boolean to determine exclusion.
no_run = true # Boolean to prevent the unit from running (even when not using `--all`).
actions = ["all"] # List of actions to exclude (e.g., "plan", "apply", "all", "all_except_output").
exclude_dependencies = true # Boolean to determine if dependencies should also be excluded.
}
# Use example module
terraform {
source = "../module"
}
inputs = {}Running the commands again produces the expected behavior, but is not DRY:
# Produces no output
$ terragrunt run -- plan
$ terragrunt run --all -- plan
❯❯ Run Summary 1 units 291ns
────────────────────────────
Excluded 1Expected behavior
Included exclude block configurations should be respected regardless of which command is used.
Versions
- Terragrunt version: v0.93.6
- OpenTofu/Terraform version: Terraform v1.13.5 on darwin_arm64
- Environment details: macOS 15.7.2 - zsh 5.9 (arm-apple-darwin24.0.0)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working