【发布时间】:2019-07-03 09:15:06
【问题描述】:
我正在尝试创建 CloudFormation 堆栈,它将创建 VPC、子网、IGW、路由表、NAT 网关、将子网与 RT 关联等
我的堆栈失败,其中 NAT 网关尝试为私有路由表创建规则以创建 NAT GW 的路由规则。
# Punblic Elastic IP for NAT Gateway in Zone 2A
eipSubnetA:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
# NAT Gateway in Public Subnet 2A
natSubnetA:
Type: AWS::EC2::NatGateway
Properties:
AllocationId:
Fn::GetAtt: [eipSubnetA, AllocationId]
SubnetId:
Ref: PRODSubnetPublic2a
Tags:
- Key: Name
Value: nat-Subnet-a
# Route through NAT Gateway
NATRoute:
Type: AWS::EC2::Route
Properties:
RouteTableId:
Ref: PRODRTPrivate
DestinationCidrBlock: 0.0.0.0/0
GatewayId:
Ref: natSubnetA
我在 CloudFormation 事件选项卡中看到的错误是:
The following resource(s) failed to create: [NATRoute]. . Rollback requested by user
Route did not stabilize in expected time
不确定我错过了什么?
# Private Subnets to Route Table Association
PrivateSubnetA:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId:
Ref: PRODSubnetPrivate2a
RouteTableId:
Ref: PRODRTPrivate
PrivateSubnetB:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId:
Ref: PRODSubnetPrivate2b
RouteTableId:
Ref: PRODRTPrivate
# Punblic Elastic IP for NAT Gateway in Zone 2A
eipSubnetA:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
# NAT Gateway in Public Subnet 2A
natSubnetA:
Type: AWS::EC2::NatGateway
Properties:
AllocationId:
Fn::GetAtt: [eipSubnetA, AllocationId]
SubnetId:
Ref: PRODSubnetPublic2a
Tags:
- Key: Name
Value: nat-Subnet-a
# Route through NAT Gateway
NATRoute:
Type: AWS::EC2::Route
Properties:
RouteTableId:
Ref: PRODRTPrivate
DestinationCidrBlock: 0.0.0.0/0
GatewayId:
Ref: natSubnetA
我希望私有路由表应该有目的地 0.0.0.0/0 的路由 NATGateway
【问题讨论】:
-
其他资源都创建成功了吗?请记住,您的 cloudformation 模板可能需要添加 DependsOn 属性的资源创建的逻辑顺序,您可以这样做,资源依赖于其他资源的创建。例如,首先您需要在创建 NATRoute 之前创建 natSubnetA 资源