2
votes

Hi I am trying to create an Amazon EC2 instance with an EBS volume. I have created a CloudFormation template:

AWSTemplateFormatVersion: "2010-09-09"
Description: "First EC2 instance"
Resources:
 FirstLinuxEC2instance:
    Type: AWS::EC2::Instance
    Properties:
      AvailabilityZone: 'ap-southeast-2a'
      ImageId: 'ami-0c1d8842b9bfc767c'
      InstanceInitiatedShutdownBehavior: 'terminate'
      InstanceType: 't2.micro'
      SecurityGroupIds:
        - 'sg-79862305'
      Volumes:
        Device: "/dev/sdf"
        VolumeId: !Ref NewVolume
 NewVolume:
  Type: AWS::EC2::Volume
  Properties:
    Size: 1
    AvailabilityZone: 'ap-southeast-2a'
    Tags:
      - Key: MyTag
        Value: TagValue
  DeletionPolicy: Snapshot

When I upload this template I am getting below error.

Value of property Volumes must be of type List

Can someone help me to figure it out the issue?

2

2 Answers

2
votes

Try this!

Volumes:
  -
   Device: "/dev/sdf"
   VolumeId: !Ref NewVolume
1
votes

Yes volumes is of type array. So even a single volume needs to be in a pair of square brackets (json). You can try cloudkast which is an online cloudformation template generator. It is very useful to make it outright clear which property is of what type with inline description.