gpt4 book ai didi

amazon-web-services - 云信息 : VPC Routing table with No Route for Internet Gateway

转载 作者:行者123 更新时间:2023-12-04 08:12:33 25 4
gpt4 key购买 nike

我正在使用 CloudFormation 创建整个堆栈。我注意到,即使我确实有 0.0.0.0/0 的路由规则来访问我的云形成模板中的互联网网关,但它并未被创建。

专有网络:

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

路由表:

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

VPCGateway附件:

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

路线:

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

互联网网关:

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

正在创建除 VPC 的 IG 路由规则之外的所有项目。 cloudformation堆栈创建没有错误。

路由表:

Destination: 172.31.0.0/16
Target: local

预期路由表:

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

请注意,我可以在创建cloudformation堆栈后直接自己添加规则。

我有什么遗漏吗?

最佳答案

联系AWS支持后,发现每个VPC都会自动创建一个路由表,并且默认为其所有子网设置路由表。解决方案是使用 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"}
}
},

关于amazon-web-services - 云信息 : VPC Routing table with No Route for Internet Gateway,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42437814/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com