我使用官方的 vpc 模块创建了 vpc 及其组件,如下所示。问题是每个子网都有自己的路由表。我想创建 2 个路由表让我们说私有和公共并将子网附加到它。 rt-私有:子网1,子网2 rt-public:subnet3,subnet4
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "2.77.0"
name = "${var.vpc_name}"
cidr = "${var.vpc_cidr}"
azs = "${var.azs}"
private_subnets = "${var.private_subnets}"
#public_subnets = "${var.public_subnets}"
enable_dns_hostnames = true
enable_dns_support = true
enable_nat_gateway = false
# single_nat_gateway = true
create_igw = false
vpc_tags = {
Environment = "${var.env}"
Automated = "Terraform"
Owner = "${var.owner}"
Project = "${var.project}"
}
private_subnet_tags = {
Environment = "${var.env}"
Automated = "Terraform"
Owner = "${var.owner}"
Project = "${var.project}"
}
public_subnet_tags = {
Environment = "${var.env}"
Automated = "Terraform"
Owner = "${var.owner}"
Project = "${var.project}"
}
private_route_table_tags = {
#Name = "${var.private_route_table_tags}"
Environment = "${var.env}"
Automated = "Terraform"
Owner = "${var.owner}"
Project = "${var.project}"
}
}