Terraform Not Creating Security Group Rules for Multiple VPCs with the Same Module
I've been banging my head against this for hours. After trying multiple solutions online, I still can't figure this out. I'm sure I'm missing something obvious here, but I'm working with an scenario where Terraform is not creating security group rules as expected when using a module for multiple VPCs in AWS. I'm using Terraform version 1.1.7 and the AWS provider version 3.54.0. I have a module that defines a security group and its rules, like this: ```hcl module "sg" { source = "./modules/security_group" vpc_id = var.vpc_id sg_name = var.sg_name rules = var.rules } ``` In my main `main.tf`, I'm calling this module twice with different VPCs: ```hcl module "sg_vpc1" { source = "./modules/security_group" vpc_id = aws_vpc.vpc1.id sg_name = "sg-vpc1" rules = [ { rule_type = "ingress", from_port = 80, to_port = 80, protocol = "tcp", cidr_blocks = ["0.0.0.0/0"] } ] } module "sg_vpc2" { source = "./modules/security_group" vpc_id = aws_vpc.vpc2.id sg_name = "sg-vpc2" rules = [ { rule_type = "ingress", from_port = 443, to_port = 443, protocol = "tcp", cidr_blocks = ["0.0.0.0/0"] } ] } ``` However, when I run `terraform apply`, I notice that only the security group for `sg_vpc1` is being created, and `sg_vpc2` does not appear in the plan at all. The output shows no errors, but it does mention `No changes. Your infrastructure matches the configuration.` which is confusing. I’ve double-checked that both VPCs are correctly defined, and each module call is distinct. I've also tried running `terraform init` and `terraform refresh`, but nothing seems to resolve the scenario. Could this be a question with how I'm passing variables to the module, or is there some limitation with managing multiple resources of the same type in a single module? Any insights would be greatly appreciated! Any help would be greatly appreciated! Is there a better approach? My team is using Hcl for this mobile app. Any feedback is welcome! I'm on Debian using the latest version of Hcl. I'm working with Hcl in a Docker container on macOS. How would you solve this?