簡體   English   中英

AWS CloudFormation:無法導入 SubnetRouteTableAssociation、VPCGatewayAttachment 和 Route 類型的資源

[英]AWS CloudFormation: Unable to import resources of type SubnetRouteTableAssociation, VPCGatewayAttachment and Route

我正在嘗試使用 CloudFormation 模板創建網絡資源,但是當我導入模板時出現以下錯誤:

資源導入不支持以下資源類型: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

您的模板中幾乎沒有錯誤

最重要的是,您不需要Route1的本地規則為172.32.0.0/16 這始終是默認創建的。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM