【问题标题】:CloudFormation Template format error: Every Parameters object must contain a Type memberCloudFormation 模板格式错误:每个参数对象都必须包含一个类型成员
【发布时间】:2019-03-29 07:53:07
【问题描述】:

我有以下非常简单的 CloudFormation 模板:

---
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

关于使用以下方法验证此模板:

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

我收到以下神秘的错误消息:

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

这是什么意思?我用谷歌搜索了这条错误消息,但一无所获。

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation


    【解决方案1】:

    错误消息可能会令人困惑 - 特别是如果您有很多参数 - 而且它似乎没有在任何地方记录。然而,在文档中提到了here

    必须为每个参数分配 AWS CloudFormation 支持的参数类型。如需更多信息,请参阅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
    

    另请参阅 Stack Overflow 上的 related questions

    【讨论】:

      猜你喜欢
      • 2017-05-30
      • 2018-06-21
      • 2018-03-31
      • 2016-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-17
      • 1970-01-01
      相关资源
      最近更新 更多