我是 terraform 的新手,正在尝试构建具有两个子网和 VPC 的基础设施。我创建了两个模块
VPC 模块将创建一个 VPC 并返回 vpc_id 作为输出,与我尝试在子网模块中使用的返回 vpc_id 相同,但当我运行 terraform 计划时,它会要求我输入 vpc_id 输入。
我想要 VPC 模块的输出值中的 vpc_id,任何人都可以帮助我吗?
下面是代码,
根 tf 文件,
provider "aws" {
shared_credentials_file = var.shared_cred
profile = "default"
region = var.aws_region
}
module "vpc" {
source = "./vpc"
name = "terraformVPC"
cidr = "10.50.40.0/27"
}
module "private_subnet" {
source = "./subnet"
subnet_name = "private_subnet"
subnet_cidr = "10.50.40.16/28"
#VPC_id = aws_vpc.moduleVPC.id
VPCid = module.vpc.outvpc_id # this is the issue
}
module "public_subnet" { …Run Code Online (Sandbox Code Playgroud)