4

I have the following very simple CloudFormation template:

---
AWSTemplateFormatVersion: 2010-09-09
Parameters:
  InstanceType:
    Description: 'EC2 Instance Type'
    Default: t2.micro
Resources:
  EC2Instance:
    Type: 'AWS::EC2::Instance'
    Properties:
      ImageId: ami-08589eca6dcc9b39c
      InstanceType: !Ref InstanceType
      KeyName: default

On validating this template using:

▶ aws cloudformation validate-template --template-body file://cloudformation.yml

I receive the following cryptic error message:

An error occurred (ValidationError) when calling the ValidateTemplate operation:
  Template format error: Every Parameters object must contain a Type member.           

What does it mean? I googled for this error message and found nothing.

1 Answer 1

10

The error message can be confusing - especially if you have a lot of parameters - and it does not appear to be documented anywhere. It is however mentioned here in the docs that:

Each parameter must be assigned a parameter type that is supported by AWS CloudFormation. For more information, see Type.

Thus to fix this template, just add a type:

---
AWSTemplateFormatVersion: 2010-09-09
Parameters:
  InstanceType:
    Type: String  ## ADD THIS LINE
    Description: 'EC2 Instance Type'
    Default: t2.micro
Resources:
  EC2Instance:
    Type: 'AWS::EC2::Instance'
    Properties:
      ImageId: ami-08589eca6dcc9b39c
      InstanceType: !Ref InstanceType
      KeyName: default

See also related questions here at Stack Overflow.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.