0
votes

I am trying to create Network resources using CloudFormation template but when I import the template i get following error:

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

Any idea what be the reason for the same. Below the code from my CF template:

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
1

1 Answers

1
votes

There are few mistakes in your template.

Most importantly you don't need Route1 with local rule of 172.32.0.0/16. This is always created by default.

Also TestDevSubnetRouteTableAssociation is missing !Ref in its parameters.

I modified your template so that it deploys now. I haven't checked its functionality, only whether it deploys.

You can use it as basis for future modification. :

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