简体   繁体   English

CloudFormation - Tansit 网关的路由表路由传播

[英]CloudFormation - Route Table route Propagation for Tansit Gateway

I am creating the following resources using CloudFormation:我正在使用 CloudFormation 创建以下资源:

  • VPC专有网络
  • Two Public Subnet两个公共子网
  • Two private Subnet两个私有子网
  • Route Tables for the Subnet's子网的路由表

I have created a site-to-site VPN with my on-prem office manually.我已经在我的本地办公室手动创建了一个站点到站点 VPN。 I have created the transit gateway manually and attached my VPN to it.我手动创建了中转网关并将我的 VPN 连接到它。 Now since I will be creating the VPC with CloudFormation, I thought to avoid manual work lets associate VPC to Transit Gateway and propagate the route in the Route Tables in the CloudFormation Script itself.现在,由于我将使用 CloudFormation 创建 VPC,我想避免手动工作让 VPC 关联到 Transit Gateway 并在 CloudFormation 脚本本身的路由表中传播路由。 Please refer the following snippet for the same:请参考以下代码片段:

  VPCTransitGateayAttachment:
    Type: AWS::EC2::TransitGatewayAttachment
    Properties: 
      SubnetIds: 
        - !Ref PrivateSubnet1
        - !Ref PrivateSubnet2
      TransitGatewayId: 'tgw-1234567890'
      VpcId: !Ref VPC

#TransitGateWay Routes
  TransitGateWayPublicRouteTableRoutes:
    Type: AWS::EC2::Route
    Properties:
      RouteTableId: !Ref PublicRouteTable
      DestinationCidrBlock: '0.0.0.0/16'
      TransitGatewayId: 'tgw-1234567890'

  TransitGateWayPrivateRouteTable1Routes:
    Type: AWS::EC2::Route
    Properties:
      RouteTableId: !Ref PrivateRouteTable1
      DestinationCidrBlock: '0.0.0.0/16'
      TransitGatewayId: 'tgw-1234567890'  

  TransitGateWayPrivateRouteTable2Routes:
    Type: AWS::EC2::Route
    Properties:
      RouteTableId: !Ref PrivateRouteTable2
      DestinationCidrBlock: '0.0.0.0/16'
      TransitGatewayId: 'tgw-1234567890'

But I am facing the following error when I execute the script.但是当我执行脚本时遇到以下错误。

The transitGateway ID 'tgw-1234567890' does not exist. (Service: AmazonEC2; Status Code: 400; Error Code: InvalidTransitGatewayID.NotFound; Request ID: 30d31120-f9e2-4870-a378-55bc9a36f5bb)

For the AWS::EC2::Route resource.对于AWS::EC2::Route资源。 I am not able to understand what is the issue.我无法理解是什么问题。 The document states the option for Transit Gateway for AWS::EC2::Route.文档说明了 AWS::EC2::Route 的 Transit Gateway 选项。 What else I am missing here ?我在这里还缺少什么?

I was facing the same issue in cloudformation, the problem was the routes must wait for the AWS::EC2::TransitGatewayAttachment , I ran the cloudformation template with all of my routes that needed the TransitGatewayId paramter commented, then uncommented the routes, and it worked.我在 cloudformation 中遇到了同样的问题,问题是路由必须等待AWS::EC2::TransitGatewayAttachment ,我运行了 cloudformation 模板,其中包含所有需要 TransitGatewayId 参数注释的路由,然后取消注释路由,然后工作。

There is documentation that this is required for internet gateways attachments, but my test shows, this is also required for TransitGatewayAttachments.文档表明 Internet 网关附件需要这样做,但我的测试表明,TransitGatewayAttachments 也需要这样做。

What we should do is add a DependsOn and that should solve the problem.我们应该做的是添加一个 DependsOn,这应该可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM