I am trying to build an aws vpc and security groups in the same module. I have this structure in my project:
.
├── README.md
├── commit.sh
├── main.tf
├── modules
│ └── networking
│ ├── README.md
│ ├── main.tf
│ ├── outputs.tf
│ └── variables.tf
├── plans
├── terraform.sh
├── variables.tf
├── vars
└── versions.tf
I am calling the module with a very simple main.tf in my project root:
## Networking
module "networking" {
source = "./modules/networking/"
}
I am needing the VPC ID for the Security Groups, and the SGs are defined as different modules inside the same file as the VPC module:
module "web_ingress_sg" {
source = "terraform-aws-modules/security-group/aws//modules/http-80"
name = "wordpress-ingress"
description = "Security group for web-server with HTTP ports open within VPC"
vpc_id = module.vpc.vpc_id
ingress_cidr_blocks = ["50.82.222.12/32"]
computed_egress_with_source_security_group_id = [
{
rule = "http-80-tcpp"
source_security_group_id = module.wordpress_instance_sg.security_group_id
},
]
}
The VPC ID is defined in the outputs.tf file in the module, but I keep getting the error msg "The argument "vpc_id" is required, but no definition was found."