我试图在同一个模块中构建一个aws vpc和安全组。我的项目中有这样的结构:
.
├── README.md
├── commit.sh
├── main.tf
├── modules
│ └── networking
│ ├── README.md
│ ├── main.tf
│ ├── outputs.tf
│ └── variables.tf
├── plans
├── terraform.sh
├── variables.tf
├── vars
└── versions.tf在我的项目根目录中,我用一个非常简单的main.tf调用模块:
## Networking
module "networking" {
source = "./modules/networking/"
}我需要用于安全组的VPC ID,SGs与VPC模块在同一个文件中定义为不同的模块:
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
},
]
}vpc_id是在模块中的outputs.tf文件中定义的,但是我一直得到错误消息“参数”"vpc_id“是必需的,但没有找到定义。
发布于 2021-08-01 03:52:03
模块不能引用自己的输出。你必须直接得到vpc id。假设您在此网络模块中定义了vpc,那么以下内容就足够了:
vpc_id = aws_vpc.vpc.vpc_idhttps://stackoverflow.com/questions/68607294
复制相似问题