1

我使用 terraform tgw 模块创建了一个中转网关,如下所示。

module "transit-gateway" {
  source          = "terraform-aws-modules/transit-gateway/aws"
  version         = "1.4.0"
  name            = "tgw-nprod"
  description     = "My TGW shared with several other AWS accounts"
  amazon_side_asn = 64532

  enable_auto_accept_shared_attachments = true
  vpc_attachments = {
    vpc1 = {
      vpc_id                                          = module.vpc.vpc_id
      subnet_ids                                      = module.vpc.private_subnets
      dns_support                                     = true
      ipv6_support                                    = false
      transit_gateway_default_route_table_association = false
      transit_gateway_default_route_table_propagation = false
    }
  }

  ram_allow_external_principals = true
  ram_principals                = [1234567890, 0987654321]

  tags = {
    Purpose = "tgw-testing"
  }
}

我使用 terraform vpc 模块创建了 vpc。

当我运行上述 terraform 时,我收到错误“错误:创建 EC2 Transit Gateway VPC 附件时出错:DuplicateSubnetsInSameZone: Duplicate Subnets for same AZ

我在 ap-south-1 中有 2 个私有子网,在 ap-south-1 中有 1 个公共子网。

4

1 回答 1

1

AWS 文档写道,您只能在每个 AZ 的一个子网中使用网关:

您必须至少选择一个子网。每个可用区只能选择一个子网。

您的错误消息表明您module.vpc.private_subnets在同一个可用区。您必须重新定义您的 VPC,使其位于两个不同的AZmodule.vpc.private_subnets中,或者仅在您的.subnet_ids

要使用一个子网:

subnet_ids                                      = [module.vpc.private_subnets[0]]
于 2021-03-17T05:43:07.093 回答