- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.1k
 
Open
Labels
bugSomething isn't workingSomething isn't workingpreservedPreserved issues never go stalePreserved issues never go stale
Description
Describe the bug
Two scenarios which are either undesirable or indeterminate exist:
- Multiple dependencies with the same name can exist in a config
 - Multiple dependencies can point to the same config_path (this was mentioned as undesireable in Support 
for_eachandcountmeta-parameters for dependencies, stacks, and units #4504) 
Adiditionally, it seems that the same behavior exists for includes
Steps To Reproduce
Includes
With same name
❯ cat terragrunt.hcl 
include "foo" {
  path = "../bar_1/terragrunt.hcl"
}
include "foo" {
  path = "../bar_2/terragrunt.hcl"
}
inputs = {
  local = "local"
}
❯ cat ../bar_1/terragrunt.hcl 
inputs = {
  bar_1 = "bar_1"
}
❯ cat ../bar_2/terragrunt.hcl
inputs = {
  bar_2 = "bar_2"
}
❯ terragrunt render
17:15:38.898 INFO   Rendering config ./terragrunt.hcl
inputs = {
  bar_1 = "bar_1"
  bar_2 = "bar_2"
  local = "local"
}With same config path
❯ cat terragrunt.hcl 
include "foo" {
  path = "../baz/terragrunt.hcl"
}
include "bar" {
  path = "../baz/terragrunt.hcl"
}
inputs = {
  local = "local"
}
❯ cat ../baz/terragrunt.hcl 
inputs = {
  included = "included"
}
❯ terragrunt render
17:12:20.501 INFO   Rendering config ./terragrunt.hcl
inputs = {
  included = "included"
  local    = "local"
}Dependencies
With same name
❯ cat terragrunt.hcl  
dependency "foo" {
  config_path = "../bar_1"
  mock_outputs = {
    path = "../bar_1"
  }
}
dependency "foo" {
  config_path = "../bar_2"
  mock_outputs = {
    path = "../bar_2"
  }
}
inputs = {
  "foo_path" = dependency.foo.outputs.path
}
❯ terragrunt render 
16:40:19.999 WARN   Failed to read outputs from ../bar_2/terragrunt.hcl referenced in ./terragrunt.hcl as foo, fallback to mock outputs. Error: Did not find any Terraform files (*.tf) or OpenTofu files (*.tofu) in ../bar_2
16:40:19.999 WARN   Failed to read outputs from ../bar_1/terragrunt.hcl referenced in ./terragrunt.hcl as foo, fallback to mock outputs. Error: Did not find any Terraform files (*.tf) or OpenTofu files (*.tofu) in ../bar_1
16:40:20.000 WARN   Config ../bar_2/terragrunt.hcl is a dependency of ./terragrunt.hcl that has no outputs, but mock outputs provided and returning those in dependency output.
16:40:20.000 WARN   Config ../bar_1/terragrunt.hcl is a dependency of ./terragrunt.hcl that has no outputs, but mock outputs provided and returning those in dependency output.
16:40:20.000 INFO   Rendering config ./terragrunt.hcl
dependency "foo" {
  config_path = "../bar_2"
  mock_outputs = {
    path = "../bar_2"
  }
}
dependency "foo" {
  config_path = "../bar_2"
  mock_outputs = {
    path = "../bar_2"
  }
}
inputs = {
  foo_path = "../bar_1"
}With same path
❯ cat terragrunt.hcl
dependency "foo" {
  config_path = "../baz"
  mock_outputs = {
    path = "../baz"
  }
}
dependency "bar" {
  config_path = "../baz"
  mock_outputs = {
    path = "../baz"
  }
}
inputs = {
  "foo_path" = dependency.foo.outputs.path
  "bar_path" = dependency.foo.outputs.path
}
❯ terragrunt render 
16:37:29.115 WARN   Failed to read outputs from ../baz/terragrunt.hcl referenced in ./terragrunt.hcl as bar, fallback to mock outputs. Error: Did not find any Terraform files (*.tf) or OpenTofu files (*.tofu) in ../baz
16:37:29.115 WARN   Config ../baz/terragrunt.hcl is a dependency of ./terragrunt.hcl that has no outputs, but mock outputs provided and returning those in dependency output.
16:37:29.116 WARN   Failed to read outputs from ../baz/terragrunt.hcl referenced in ./terragrunt.hcl as foo, fallback to mock outputs. Error: Did not find any Terraform files (*.tf) or OpenTofu files (*.tofu) in ../baz
16:37:29.116 WARN   Config ../baz/terragrunt.hcl is a dependency of ./terragrunt.hcl that has no outputs, but mock outputs provided and returning those in dependency output.
16:37:29.116 INFO   Rendering config ./terragrunt.hcl
dependency "foo" {
  config_path = "../baz"
  mock_outputs = {
    path = "../baz"
  }
}
dependency "bar" {
  config_path = "../baz"
  mock_outputs = {
    path = "../baz"
  }
}
inputs = {
  bar_path = "../baz"
  foo_path = "../baz"
}Expected behavior
Validation exists for these scenarios and throws an error when they occur.
Nice to haves
- Terminal output
 - Screenshots
 
Versions
- Terragrunt version: v0.85.0
 
Additional context
javier-gascon
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpreservedPreserved issues never go stalePreserved issues never go stale