terragrunt
terragrunt copied to clipboard
Dependency cycles
Hello ! I have a dependency cycle issue that is driving me crazy. this is the structure of my code
|── deployment
│ |── module1
│ │ └── terragrunt.hcl
│ |── module2
│ │ └── terragrunt.hcl
└── ressources
│ |── module1
│ │ └── azuredeploy.tf
│ |── module2
│ │ └── azuredeploy.tf
The problem is the following :
I need to access, from module 1, output values exposed by module 2 and vice versa. As such, used dependency blocks in module 1 and module 2 :
terragrunt.hcl (from module 1) looks like this
terraform {
# Deploy develop branch
source = "the path of my 1st terraform module"
}
dependency "module2" {
config_path = "../module2"
mock_outputs_allowed_terraform_commands = ["validate", "plan"]
mock_outputs = {
value1 = "random_number"
}
}
inputs={
value1 = "random_number"
}
the problem is that by adding a dependency block in the 2nd terragrunt module, I have a cycle dependency. What should I do to break the cycle ? thanks for your help
Hi,
not sure if Terragrunt has now an option to resolve dependencies cycles, most probably should be introduced another module that will output required values for module1/module2
I am facing the same thing, driving me nuts, I don't want to rewrite modules just to make it work. I am trying to switch from terraform module structure which I have no problems with, I want terragrunt to give the ci/cd flexibility for some resources that need to be applied first before other resources can (like transit gateway before private eks). In the current loop, I am building eks node role arn in eks module, which needs to be passed to policy which then needs to be passed to km key creation with a policy which then needs to be passed back to eks module for ebs block with kms key. eventually, I included the policy data resource and kms resource in eks module using generate in terragrunt.hcl, but now I am faced with an issue that I need the arns from kms to be passed using "inputs", I am going crazy with this. I still have hopes...