spunkyquagga
spunkyquagga

Reputation: 91

How to fix cloudformation template which creates EC2 along with AWS::CloudFormation::Init

I am deploying a stack using a cloudformation template which creates EC2 with cloud-init section. When I deploy it, i get this error message:

The following resource(s) failed to create: [EC2Instance]. . The requested configuration is currently not supported. Please check the documentation for supported configurations.

If I remove the "Metadata" section, everything works and an EC2 is created. Something might be misconfigured in the metadata section and I am not able to figure out what is.

I am using this documentation as a reference -> https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html

AWSTemplateFormatVersion: 2010-09-09
Resources:
  EC2Instance:
    Type: 'AWS::EC2::Instance'
    Metadata: 
      AWS::CloudFormation::Init: 
        configSets: 
          config: 
            - "config1"
            - "config2"
        config1: 
          commands: 
            test: 
              command: "echo \"hello from config 1\" > test.txt"
        config2: 
          commands: 
            test: 
              command: "echo \"hello from config 2\" > test.txt"
    Properties:
      InstanceType: "t2.small"
      ImageId: "ami-06b382aba6c5a4f2c"
      SecurityGroupIds:
        - "sg-123456"
      SubnetId: "subnet-123456"
      KeyName: "my-example-key"

I expect the EC2 Instance to be created but I get the following error message:

The requested configuration is currently not supported. Please check the documentation for supported configurations. (Service: AmazonEC2; Status Code: 400; Error Code: Unsupported; Request ID: --Redacted--)

Upvotes: 1

Views: 1861

Answers (1)

xeon
xeon

Reputation: 954

The AMI used here is ami-06b382aba6c5a4f2c, which is for 64-bit Arm. The instance type family is t2. The supported instance family for ami-06b382aba6c5a4f2c is a1.

If you want to use AMZ linux 2, use the AMI ami-0de53d8956e8dcf80, which is built for the architecture 64-bit (x86).

In a nutshell, change the ImageId to 'ami-0de53d8956e8dcf80'

Hope this helps..

Upvotes: 3

Related Questions