两个 public VPC 之间的 AWS Cloudformation VPCPeeringConnection

AWS Cloudformation VPCPeeringConnection between two public VPC's

我有很大的 AWS Cloudformation 并且有任务将一些资源与两个 VPC 分开。两者都应该具有 public 资源并且在相同的可用性区域中。他们可以使用相同的 InternetGateway。它只是额外的安全任务。

我有点困惑。

从例子中我看到我应该像那样使用 VPCPeeringConnection:

    "myVPCPeeringConnection": {
           "Type": "AWS::EC2::VPCPeeringConnection",
            "Properties": {
                "VpcId": {"Ref": "myVPC"},
                "PeerVpcId": {"Ref": "myPrivateVPC"}
            }
     }

但是他们在 public 资源和私有资源之间建立对等互连,而我需要在 VPC 中的 public 资源之间建立对等互连。

我是否也应该为它们分别创建子网、RouteTable、InternetGateway、VPCGatewayAttachment、PublicNetworkAcl、Route? 或者我可以将它们全部用于两者?

谢谢!

tl;dr -- 为两个 VPC 提供各自所需的独立资源集。

They can use the same Internet Gateway.

不,他们不能。 Internet 网关、NAT 实例、NAT 网关、VPN、Direct Connect 和 VPC 服务端点不能跨对等连接共享。

http://docs.aws.amazon.com/AmazonVPC/latest/PeeringGuide/invalid-peering-configurations.html#edge-to-edge-vgw

路由表也是如此。在对等 VPC 中,路由表必须不同,因为每个 VPC 都需要路由指向另一个。

http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Route_Tables.html#route-tables-vpc-peering

当然,每个 VPC 中的子网也不能重叠,否则无法进行对等。

But they put peering between public and private, and I need to peer two between public VPC's.

这是随意的术语。对于 VPC,实际上并没有 "public" 或 "private" 这样的区别。

VPC 是被考虑 public 还是私有只是与您如何使用 VPC 相关的任意指定——例如,您可能在 VPC 中拥有您称为 "private" 的数据库和您称为 "public," 的 VPC 中的 Web 服务器,但这两种 "different" 类型的 VPC 之间没有明确的技术区别。