Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CloudFormation Template format error: Every Parameters object must contain a Type member

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.

like image 574
Alex Harvey Avatar asked Jan 01 '23 03:01

Alex Harvey


1 Answers

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.

like image 135
Alex Harvey Avatar answered Jan 03 '23 16:01

Alex Harvey