如何从 vpc terraform 模块创建单个公共和私有路由表

时间:2021-03-16 14:54:00

标签: terraform terraform-provider-aws terraform0.12+ terraform-modules

我使用 terraform vpc 模块创建 vpc,我的 vpc 没有 igw 和 nat 网关。现在的问题是不同子网有不同的路由表。我想将所有私有子网连接到单个私有 rt,将公共子网连接到公共 rt。

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}"
  }

  private_subnet_tags = {
    Environment = "${var.env}"
  }

  public_subnet_tags = {
    Name = "${var.public_subnet_dmz_tag}"
    Environment = "${var.env}"
  }

  private_route_table_tags = {
    Name        = "${var.private_route_table_tags}"
    Environment = "${var.env}"
  }

  public_route_table_tags = {
    Name        = "${var.public_route_table_tags}"
    Environment = "${var.env}"
  }
}

0 个答案:

没有答案