Amazon web services 获取现有资源的云形成中的InvalidRouteTableID.NotFound
运行时,我在云形成堆栈中反复得到一个Amazon web services 获取现有资源的云形成中的InvalidRouteTableID.NotFound,amazon-web-services,amazon-cloudformation,Amazon Web Services,Amazon Cloudformation,运行时,我在云形成堆栈中反复得到一个InvalidRouteTableID.NotFound aws cloudformation create-stack --stack-name sample --template-body file://aws-network.yml 我不知道为什么 这是我的cloudformation模板aws network.yml。它相当标准,它创建VPC、子网、internet网关、弹性ip地址、nat网关、路由表和关联 AWSTemplateFormatVer
InvalidRouteTableID.NotFound
aws cloudformation create-stack --stack-name sample --template-body file://aws-network.yml
我不知道为什么
这是我的cloudformation模板aws network.yml
。它相当标准,它创建VPC、子网、internet网关、弹性ip地址、nat网关、路由表和关联
AWSTemplateFormatVersion: 2010-09-09
# This CloudFormation template deploys a basic VPC / Network.
Resources:
vpc:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsHostnames: true
EnableDnsSupport: false
InstanceTenancy: default
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-vpc"]]
internetGateway:
Type: AWS::EC2::InternetGateway
DependsOn: vpc
Properties:
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-igw"]]
attachGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref vpc
InternetGatewayId: !Ref internetGateway
publicSubnetA:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref vpc
CidrBlock: 10.0.10.0/24
AvailabilityZone: !Select [ 0, !GetAZs ]
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-public-a"]]
publicSubnetB:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref vpc
CidrBlock: 10.0.20.0/24
AvailabilityZone: !Select [ 1, !GetAZs ]
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-public-b"]]
privateSubnetA:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref vpc
CidrBlock: 10.0.30.0/24
AvailabilityZone: !Select [ 0, !GetAZs ]
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-private-a"]]
privateSubnetB:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref vpc
CidrBlock: 10.0.40.0/24
AvailabilityZone: !Select [ 1, !GetAZs ]
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-private-b"]]
publicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref vpc
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-public"]]
publicRoute1:
Type: AWS::EC2::Route
DependsOn: attachGateway
Properties:
RouteTableId: !Ref publicRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref internetGateway
natGateway: # it has a cost https://aws.amazon.com/vpc/pricing/
Type: AWS::EC2::NatGateway
Properties:
AllocationId: !GetAtt elasticIpAddress.AllocationId # gets the allocation Id from the elasticIpAddress resource
SubnetId: !Ref publicSubnetA # only associated to a public subnet to simplify and reduce costs
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-nat"]]
elasticIpAddress:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
privateRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref vpc
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-private"]]
privateRoute1:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref privateRouteTable
DestinationCidrBlock: 0.0.0.0/0
NateGatewayId: !Ref natGateway
publicSubnetARouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref publicSubnetA
RouteTableId: publicRouteTable
publicSubnetBRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref publicSubnetB
RouteTableId: publicRouteTable
privateSubnetARouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref privateSubnetA
RouteTableId: privateRouteTable
privateSubnetBRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref privateSubnetB
RouteTableId: privateRouteTable
根据事件,这不应该发生,正如我所看到的,顺序如下:
2021-04-21 17:04:05 UTC+0200 privateRouteTable
CREATE_COMPLETE -
2021-04-21 17:04:05 UTC+0200 publicRouteTable
CREATE_COMPLETE -
2021-04-21 17:04:22 UTC+0200 privateSubnetBRouteTableAssociation
CREATE_FAILED The routeTable ID 'privateRouteTable' does not exist (Service: AmazonEC2; Status Code: 400; Error Code: InvalidRouteTableID.NotFound; Request ID: b51b2b9c-af12-4376-b6e4-1698624f7522; Proxy: null)
2021-04-21 17:04:22 UTC+0200 publicSubnetBRouteTableAssociation
CREATE_FAILED The routeTable ID 'publicRouteTable' does not exist (Service: AmazonEC2; Status Code: 400; Error Code: InvalidRouteTableID.NotFound; Request ID: 5cb26e14-13ca-4915-9973-109dd44c5b2e; Proxy: null)
2021-04-21 17:04:22 UTC+0200 attachGateway
CREATE_FAILED Resource creation cancelled
2021-04-21 17:04:23 UTC+0200 privateSubnetARouteTableAssociation
CREATE_FAILED Resource creation cancelled
2021-04-21 17:04:23 UTC+0200 publicSubnetARouteTableAssociation
CREATE_FAILED Resource creation cancelled
2021-04-21 17:04:23 UTC+0200 natGateway
CREATE_FAILED Resource creation cancelled
2021-04-21 17:04:24 UTC+0200 rubiko
ROLLBACK_IN_PROGRESS The following resource(s) failed to create: [publicSubnetBRouteTableAssociation, attachGateway, privateSubnetBRouteTableAssociation, natGateway, publicSubnetARouteTableAssociation, privateSubnetARouteTableAssociation]. Rollback requested by user.
知道为什么没有找到一些创建的资源吗
谢谢解决了,我忘了
!Ref
(今天到此为止)
这是正确的模板
AWSTemplateFormatVersion: 2010-09-09
# This CloudFormation template deploys a basic VPC / Network.
Resources:
vpc:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsHostnames: true
EnableDnsSupport: false
InstanceTenancy: default
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-vpc"]]
internetGateway:
Type: AWS::EC2::InternetGateway
DependsOn: vpc
Properties:
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-igw"]]
attachGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref vpc
InternetGatewayId: !Ref internetGateway
publicSubnetA:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref vpc
CidrBlock: 10.0.10.0/24
AvailabilityZone: !Select [ 0, !GetAZs ]
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-public-a"]]
publicSubnetB:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref vpc
CidrBlock: 10.0.20.0/24
AvailabilityZone: !Select [ 1, !GetAZs ]
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-public-b"]]
privateSubnetA:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref vpc
CidrBlock: 10.0.30.0/24
AvailabilityZone: !Select [ 0, !GetAZs ]
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-private-a"]]
privateSubnetB:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref vpc
CidrBlock: 10.0.40.0/24
AvailabilityZone: !Select [ 1, !GetAZs ]
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-private-b"]]
publicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref vpc
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-public"]]
publicRoute1:
Type: AWS::EC2::Route
DependsOn: attachGateway
Properties:
RouteTableId: !Ref publicRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref internetGateway
natGateway: # it has a cost https://aws.amazon.com/vpc/pricing/
Type: AWS::EC2::NatGateway
Properties:
AllocationId: !GetAtt elasticIpAddress.AllocationId # gets the allocation Id from the elasticIpAddress resource
SubnetId: !Ref publicSubnetA # only associated to a public subnet to simplify and reduce costs
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-nat"]]
elasticIpAddress:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
privateRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref vpc
Tags:
- Key: Name
Value: !Join ['', [!Ref "AWS::StackName", "-private"]]
privateRoute1:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref privateRouteTable
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref natGateway
publicSubnetARouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref publicSubnetA
RouteTableId: !Ref publicRouteTable
publicSubnetBRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref publicSubnetB
RouteTableId: !Ref publicRouteTable
privateSubnetARouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref privateSubnetA
RouteTableId: !Ref privateRouteTable
privateSubnetBRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref privateSubnetB
RouteTableId: !Ref privateRouteTable
全归功于迈克·阿特金森