简体   繁体   English

Cloudformation:没有Internet路由的VPC路由表

[英]Cloudformation: VPC Routing table with No Route for Internet Gateway

I am creating a whole stack using CloudFormation. 我正在使用CloudFormation创建整个堆栈。 I have noticed that even though I do have a routing rule for 0.0.0.0/0 to access an internet gateway in my cloud formation template, it is not being created. 我注意到即使我有一个0.0.0.0/0的路由规则来访问我的云形成模板中的Internet网关,它也没有被创建。

VPC: VPC:

"vpc": {
  "Type": "AWS::EC2::VPC",
  "Properties": {
    "CidrBlock": "172.31.0.0/16",
    "InstanceTenancy": "default",
    "EnableDnsSupport": "true",
    "EnableDnsHostnames": "true",
    "Tags": [
      {
        "Key": "Environment",
        "Value": {
          "Ref": "Env"
        }
      }
    ]
  }

Routing table: 路由表:

"rtb": {
  "Type": "AWS::EC2::RouteTable",
  "Properties": {
    "VpcId": {
      "Ref": "vpc"
    }
  },
  "Metadata": {
    "AWS::CloudFormation::Designer": {
      "id": "65297cdc-8bcd-482d-af40-b0fef849b8c2"
    }
  }
}

VPCGatewayAttachment: VPCGatewayAttachment:

"gw1": {
  "Type": "AWS::EC2::VPCGatewayAttachment",
  "Properties": {
    "VpcId": {
      "Ref": "vpc"
    },
    "InternetGatewayId": {
      "Ref": "ig"
    }
  },
  "Metadata": {
    "AWS::CloudFormation::Designer": {
      "id": "aa69d6c0-3b11-43be-a8c1-7e79176f8c89"
    }
  }
}

Route: 路线:

"route1": {
  "Type": "AWS::EC2::Route",
  "Properties": {
    "DestinationCidrBlock": "0.0.0.0/0",
    "RouteTableId": {
      "Ref": "rtb"
    },
    "GatewayId": {
      "Ref": "ig"
    }
  },
  "DependsOn": "gw1",
  "Metadata": {
    "AWS::CloudFormation::Designer": {
      "id": "a68dd12e-3c14-4fa9-ba36-e0046374a0e9"
    }
  }
}

Internet Gateway: 互联网网关:

"ig": {
  "Type": "AWS::EC2::InternetGateway",
  "Properties": {},
  "Metadata": {
    "AWS::CloudFormation::Designer": {
      "id": "9f9b4ce3-b994-43ff-9155-04aeb7ab2edf"
    }
  }
}

All of the items are being created, except the IG routing rule for the VPC. 除了VPC的IG路由规则之外,正在创建所有项目。 There are no errors in the cloudformation stack creation. cloudformation堆栈创建中没有错误。

The routing table: 路由表:

Destination: 172.31.0.0/16
Target: local

Expected routing table: 预期的路由表:

Destination: 172.31.0.0/16
Target: local
Destination: 0.0.0.0/0
Target: igw-********

Note that I can add the rule by myself directly after cloudformation stack creation. 请注意,我可以在创建cloudformation堆栈后直接添加规则。

Is there something I am missing? 有什么我想念的吗?

After contacting AWS support, it turned out that each VPC creates a routing table automatically and it is set by default for all of its subnets. 在联系AWS支持后,结果发现每个VPC都会自动创建一个路由表,默认情况下会为其所有子网设置。 The solution to that would be to use a SubnetRouteTableAssociation to associate my new route table with each subnet. 解决方案是使用SubnetRouteTableAssociation将我的新路由表与每个子网相关联。

    "subnet0RTA": {
      "Type" : "AWS::EC2::SubnetRouteTableAssociation",
      "Properties" : {
        "RouteTableId" : {"Ref" : "rtb"},
        "SubnetId" : {"Ref" : "subnet0"}
      }
    },
    "subnet1RTA": {
      "Type" : "AWS::EC2::SubnetRouteTableAssociation",
      "Properties" : {
        "RouteTableId" : {"Ref" : "rtb"},
        "SubnetId" : {"Ref" : "subnet1"}
      }
    },

暂无
暂无

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

相关问题 CloudFormation - Tansit 网关的路由表路由传播 - CloudFormation - Route Table route Propagation for Tansit Gateway AWS VPC - 添加到附加到 Internet 网关的公共路由表的私有子网 - AWS VPC - Private subnet added to the public route table attached to internet gateway 如果我不想访问互联网,是否需要 VPC 中的 NAT 网关和路由表? - Do I need NAT gateway and route table in a VPC if I don't want internet access? Cloudformation - 路由表与网关有冲突的关联 - Cloudformation - Route table has a conflicting association with the gateway AWS CloudFormation:如何在cloudformation模板中引用默认/主路由表(在创建VPC时创建)? - AWS CloudFormation: how do I refer to the default/main route table (that is created when a VPC is created) in a cloudformation template? AWS 和 CloudFormation:如何将虚拟私有网关附加到路由表? - AWS and CloudFormation: How to attach a Virtual Private Gateway to a Routing Table? 在cloudformation中将对API Gateway端点的访问限制为VPC - Restrict acces to API Gateway endpoint to VPC in cloudformation Internet Gateway的AWS CloudFormation错误 - AWS CloudFormation Errors with Internet Gateway 我们如何使用 AWS CloudFormation 中的 Get::Attr 获取 VPC 的默认路由表 ID? - How can we get a VPC's default route table ID using Get::Attr in AWS CloudFormation? Terraform:导入现有的互联网网关并附加到 vpc - Terraform : Import existing internet gateway and attach to vpc
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM