Open nabilbendafi opened 1 day ago
This is causing this problem https://github.com/cloudposse/terraform-aws-security-group/blob/276a4949330eba485147edc56c5f584b1298cbab/main.tf#L81-L109
The fact that the module can handle inline, even if inline is disabled, that does not matter. Here is simplistic example to demonstrate that:
Two invocation of the same module, passing cross-reference from the output
module "sg_1" {
source = "./module"
rules = [module.sg_2.id]
}
module "sg_2" {
source = "./module"
rules = [module.sg_1.id]
}
2. module itself
```hcl
variable "rules" {
type = list(any)
}
resource "aws_security_group" "default" {
dynamic "does_not_matter_what" {
for_each = var.rules # it can be local behind some flag, it does not matter
content {
does_not_matter_what = ""
}
}
}
output "id" {
value = aws_security_group.default.id
}
╷
│ Error: Cycle: module.sg_2.aws_security_group.default, module.sg_2.output.id (expand), module.sg_1.var.rules (expand), module.sg_1.aws_security_group.default, module.sg_1.output.id (expand), module.sg_2.var.rules (expand)
│
│
╵
Describe the Bug
Trying to move from
https://github.com/terraform-aws-modules/terraform-aws-security-group
, a simple declaration ofSecurity Group rules
for two newSecurity Group
in order to:creates a cycle and Terraform is not able to perform a plan.
Use case:
(where setting
allow_all_egress
totrue
is not an option, from a security point of view)Expected Behavior
Terraform plan finishes without error about cycle dependency.
Steps to Reproduce
Run
with following code:
Screenshots
No response
Environment
Terraform v1.7.4 on darwin_arm64
Additional Context
Same "code" with
terraform-aws-modules/security-group/aws
implementation produces no errorand plan seems consistent with expected output