gpt4 book ai didi

amazon-web-services - 在云结构中获取存在资源的 InvalidRouteTableID.NotFound

转载 作者:行者123 更新时间:2023-12-03 07:41:17 32 4
gpt4 key购买 nike

运行时,我在云形成堆栈中反复收到 InvalidRouteTableID.NotFound

aws cloudformation create-stack --stack-name sample --template-body file://aws-network.yml

我不知道为什么。

这是我的 cloudformation 模板 aws-network.yml。它非常标准,它创建 VPC、子网、互联网网关、弹性 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

所有功劳都归功于迈克·阿特金森!

关于amazon-web-services - 在云结构中获取存在资源的 InvalidRouteTableID.NotFound,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67198542/

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