gpt4 book ai didi

amazon-web-services - AWS CloudFormation : Unable to import resources of type SubnetRouteTableAssociation, VPCGatewayAttachment 和路由

转载 作者:行者123 更新时间:2023-12-03 07:20:40 26 4
gpt4 key购买 nike

我正在尝试使用 CloudFormation 模板创建网络资源,但是当我导入模板时出现以下错误:

The following resource types are not supported for resource import: AWS::EC2::SubnetRouteTableAssociation,AWS::EC2::VPCGatewayAttachment,AWS::EC2::Route,AWS::EC2::Route

知道同样的原因是什么吗?下面是我的 CF 模板中的代码:

AWSTemplateFormatVersion: 2010-09-09
Resources:
TestDevVPC:
Type: 'AWS::EC2::VPC'
Properties:
CidrBlock: 172.32.0.0/16
Tags:
- Key: Description
Value: Created for Test development
PublicSubnet:
Type: 'AWS::EC2::Subnet'
Properties:
CidrBlock: 172.32.1.0/24
MapPublicIpOnLaunch: true
VpcId: !Ref TestDevVPC
Tags:
- Key: Description
Value: Public subnet for Test build
TestDevPublicRouteTable:
Type: 'AWS::EC2::RouteTable'
Properties:
VpcId: !Ref TestDevVPC
Tags:
- Key: Description
Value: public route table
TestDevInternetGateway:
Type: 'AWS::EC2::InternetGateway'
Properties:
Tags:
- Key: Description
Value: Internet Gateway for Test Dev
TestDevIGVPCAttach:
Type: 'AWS::EC2::VPCGatewayAttachment'
Properties:
InternetGatewayId: !Ref TestDevInternetGateway
VpcId: !Ref TestDevVPC
TestDevSubnetRouteTableAssociation:
Type: 'AWS::EC2::SubnetRouteTableAssociation'
Properties:
RouteTableId: TestDevPublicRouteTable
SubnetId: PublicSubnet
Route1:
Type: 'AWS::EC2::Route'
Properties:
DestinationCidrBlock: 172.32.0.0/16
RouteTableId: !Ref TestDevPublicRouteTable
Route2:
Type: 'AWS::EC2::Route'
Properties:
DestinationCidrBlock: 0.0.0.0/0
RouteTableId: !Ref TestDevPublicRouteTable
GatewayId: !Ref TestDevInternetGateway

最佳答案

您的模板中几乎没有错误

最重要的是,您不需要本地规则为 172.32.0.0/16Route1。这始终是默认创建的。

此外,TestDevSubnetRouteTableAssociation 的参数中缺少 !Ref

我修改了您的模板,以便立即部署。我没有检查它的功能,只检查它是否部署。

您可以将其用作将来修改的基础。 :

AWSTemplateFormatVersion: 2010-09-09

Resources:

TestDevVPC:
Type: 'AWS::EC2::VPC'
Properties:
CidrBlock: 172.32.0.0/16
Tags:
- Key: Description
Value: Created for Test development

PublicSubnet:
Type: 'AWS::EC2::Subnet'
Properties:
CidrBlock: 172.32.1.0/24
MapPublicIpOnLaunch: true
VpcId: !Ref TestDevVPC
Tags:
- Key: Description
Value: Public subnet for Test build

TestDevPublicRouteTable:
Type: 'AWS::EC2::RouteTable'
Properties:
VpcId: !Ref TestDevVPC
Tags:
- Key: Description
Value: public route table

TestDevInternetGateway:
Type: 'AWS::EC2::InternetGateway'
Properties:
Tags:
- Key: Description
Value: Internet Gateway for Test Dev

TestDevIGVPCAttach:
Type: 'AWS::EC2::VPCGatewayAttachment'
Properties:
InternetGatewayId: !Ref TestDevInternetGateway
VpcId: !Ref TestDevVPC


Route2:
Type: 'AWS::EC2::Route'
Properties:
DestinationCidrBlock: 0.0.0.0/0
RouteTableId: !Ref TestDevPublicRouteTable
GatewayId: !Ref TestDevInternetGateway

TestDevSubnetRouteTableAssociation:
Type: 'AWS::EC2::SubnetRouteTableAssociation'
Properties:
RouteTableId: !Ref TestDevPublicRouteTable
SubnetId: !Ref PublicSubnet

关于amazon-web-services - AWS CloudFormation : Unable to import resources of type SubnetRouteTableAssociation, VPCGatewayAttachment 和路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62480645/

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