2

I'm trying to use CloudFormation to deploy two Windows Server 2019 EC2 instances and also attach a new volume to each instance (two instances, two volumes total). I get the following error when I deploy:

Value of property Tags must be of type List

From my research, it sounds like the way I'm referencing the volumes I'm trying to create could be the issue but not sure.

Here's some of my template for reference:

Resources:
  rpt04:
    Type: 'AWS::EC2::Instance'
    Properties:
      AvailabilityZone: us-west-1
      InstanceType: t2.large
      ImageId: ami-0cc5ea3dde5301489
      Tags:
        - Key: "Name"
          Value: "RPT-04 (W2K16)"
      KeyName: Key_2020
      SecurityGroupIds: 
        - sg-f2bcJmn9
      SubnetId: subnet-19234d70 
      BlockDeviceMappings:
        - DeviceName: /dev/sda1
          Ebs:
            VolumeSize: 100
            DeleteOnTermination: true
      Volumes:
        -
         Device: xvdb
         VolumeId: !Ref rpt04appvolume
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 357656a6-846b-4674-b06a-22901916ff91

   rpt04appvolume:
    Type: 'AWS::EC2::Volume'
    Properties:
      AvailabilityZone: us-west-1
      Size: 100
      VolumeType: gp2
      Tags:
         Key: Name
         Value: RPT-04-APP
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 3340c328-2324-42e5-bd11-b3c1d1f41a09

I'd appreciate any help/assistance on this. I'm new to CloudFormation and stuck on this one.

2 Answers 2

0

In rpt04appvolume you're missing a - in Tags:

Change it from this:

   rpt04appvolume:
    Type: 'AWS::EC2::Volume'
    Properties:
      ...
      Tags:
         Key: Name
         Value: RPT-04-APP

to this:

   rpt04appvolume:
    Type: 'AWS::EC2::Volume'
    Properties:
      ...
      Tags:
      -  Key: Name               # Note the '-'
         Value: RPT-04-APP

By the way - AvailabilityZone: us-west-1 should instead be us-west-1a or b or something. That us-west-1 alone is a region name not an availability zone name.

Hope that helps :)

1
  • I ended up having to add additional spacing and the '-' dash mark in the ec2 'volumes' resource section and in the volumes resource 'tags' section like you mentioned above. Thanks for the response!
    – jrd1989
    May 28, 2020 at 13:43
1

Here's an example which shows multiple tags. The instance type is Linux, but Windows is the same in CF.

What I've copied a mix of a template that I use regularly with a few of your IDs copied in. My actual template heavily references resources I've created in other templates with !ImportValue and things defined in this template with !Ref

EC2Instance:
  Type: 'AWS::EC2::Instance'
  Properties:
    InstanceType: t3a.nano
    ImageId: ami-0970010f37c4f9c8d
    SubnetId:
      subnet-19234d70 
    SecurityGroupIds:
      - sg-f2bcJmn9
    AvailabilityZone: ap-southeast-2
    BlockDeviceMappings:
    - DeviceName: "/dev/xvda"
      Ebs:
        VolumeSize: '8'
        Encrypted: 'true'
    Tags:
      - Key: Name
        Value: Fred the VM
      - Key: environment
        Value: Production
      - Key: favorite_color
        Value: red

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .