Terraform 1.4.3: scenarios with AWS Security Group Rules Due to Dependency Cycle
Could someone explain I'm following best practices but Quick question that's been bugging me - I'm working with a frustrating scenario while trying to set up AWS security groups with Terraform 1.4.3... I have multiple security groups that are supposed to reference each other, but I'm getting a `behavior: Cycle: ...` message whenever I run `terraform apply`. My goal is to create a set of security groups where each security group allows traffic from the other. Hereโs a simplified version of my configuration: ```hcl resource "aws_security_group" "web_sg" { name = "web_sg" vpc_id = aws_vpc.my_vpc.id ingress { from_port = 80 to_port = 80 protocol = "tcp" security_groups = [aws_security_group.app_sg.id] } } resource "aws_security_group" "app_sg" { name = "app_sg" vpc_id = aws_vpc.my_vpc.id ingress { from_port = 443 to_port = 443 protocol = "tcp" security_groups = [aws_security_group.web_sg.id] } } ``` I've tried adjusting the dependencies using `depends_on`, but it didnโt help resolve the cycle. I also attempted to create the security groups separately and then use `terraform apply`, but the same behavior occurs. Iโve confirmed that my VPC ID is correct and that both security groups are deployed in the same region. Does anyone have insight on how to resolve this dependency cycle scenario? Is there a recommended approach for creating interdependent security groups in Terraform? Any tips would be greatly appreciated! My development environment is Ubuntu. How would you solve this? This is part of a larger desktop app I'm building. Any advice would be much appreciated. I'm working with Hcl in a Docker container on Ubuntu 22.04.