Skip to main content
Knowledge Base

ERRO[0000] Found a dependency cycle between modules:

Answer

> I am creating two Security Groups, One for Application SG and Second one is RDS SG Application SG Module1: ================== include "root" { path = find_in_parent_folders() expose = true } dependency "vpc" { config_path = "../../vpc" mock_outputs = { vpc_id = "temporary-dummy-id" } } dependency sg-rds { config_path = "../rds" mock_outputs = { security_group_id = "temporary-dummy-id" } skip_outputs = true } dependencies { paths = ["../rds"] } terraform { source = "github.com/terraform-aws-modules/terraform-aws-security-group.git?ref=v4.3.0" } inputs = { name = "${include.root.locals.prj}-app-sg-${include.root.locals.env}-${include.root.locals.aws_region}" use_name_prefix = false vpc_id = dependency.vpc.outputs.vpc_id egress_with_source_security_group_id = [ { from_port = 3306 to_port = 3306 protocol = "tcp" description = "Allow access to connect MySQL" source_security_group_id = dependency.sg-rds.outputs.security_group_id } ] } ======================== RDS SG `Module2` =================== include "root" { path = find_in_parent_folders() expose = true } dependency "vpc" { config_path = "../../vpc" mock_outputs = { vpc_id = "temporary-dummy-id" vpc_cidr_block = "10.0.0.0/16" } } dependency sg-app-ec2 { config_path = "../app-ec2" mock_outputs = { security_group_id = "temporary-dummy-id" } } dependencies { paths = ["../app-ec2"] } terraform { source = "github.com/terraform-aws-modules/terraform-aws-security-group.git?ref=v4.3.0" } inputs = { name = "${include.root.locals.prj}-rds-sg-${include.root.locals.env}-${include.root.locals.aws_region}" use_name_prefix = false vpc_id = dependency.vpc.outputs.vpc_id ingress_with_source_security_group_id = [ { from_port = 3306 to_port = 3306 protocol = "tcp" description = "Allow access to connect MySQL" source_security_group_id = dependency.sg-rds.outputs.security_group_id } ] } ================================================= AM running the below commands terragrunt run-all plan and getting below error ERRO[0000] Found a dependency cycle between modules: Let us know how to pass dependency variables between two modules --- <ins datetime="2022-08-04T05:28:30Z"> <p><a href="https://support.gruntwork.io/hc/requests/109098">Tracked in ticket #109098</a></p> </ins>

First of all, the creative formatting of the code in your post makes it difficult to read. Just a minor note that I wanted to share for the sake of yourself and everyone else in the future. Second, and most important, Gruntwork does not maintain modules within `github.com/terraform-aws-modules`. We suggest you ask about this issue over there. (Be sure to format correctly!) Thirdly, as we maintain Terragrunt, `terragrunt run-all plan` is not a reliable command in all cases. Please see the [documentation](https://terragrunt.gruntwork.io/docs/features/execute-terraform-commands-on-multiple-modules-at-once/#the-run-all-command) on `run-all`, especially the section on `plan`.