【问题标题】:EC2 Cloud Formation - Error MessageEC2 云形成 - 错误消息
【发布时间】:2018-08-09 00:55:46
【问题描述】:

这是我的 cloudFormation 模板。

描述:创建可变数量的 EC2 实例资源。

参数:

  InstanceCount:
    Description: Number of EC2 instances (must be between 1 and 3).
    Type: Number
    Default: 1
    MinValue: 1
    MaxValue: 3
    ConstraintDescription: Must be a number between 1 and 3.
    Description: launch EC2 instances.
    Type: AWS::EC2::Instance

InstanceType:
    Description: Launch EC2 instances.
    Type: String
    Default: t2.micro
    AllowedValues: [ t2.micro ]

Conditions:
  Launch1: !Equals [1, 1]
  Launch2: !Not [!Equals [1, !Ref InstanceCount]]
  Launch3: !Or
  - !Not [!Equals [1, !Ref InstanceCount]]
  - !Not [!Equals [2, !Ref InstanceCount]]


**Resources:**

Instance1:
    Condition: Launch1
    Type: AWS::EC2::Instance
    Properties:
      InstanceType: !Ref InstanceType
      AvailabilityZone: us-east-1a
      ImageId: ami-a4c7edb2

Instance2:
    Condition: Launch2
    Type: AWS::EC2::Instance
    Properties:
      InstanceType: !Ref InstanceType
      AvailabilityZone: us-east-1b
      ImageId: ami-a4c7edb2

Instance3:
    Condition: Launch3
    Type: AWS::EC2::Instance
    Properties:
      InstanceType: !Ref InstanceType
      AvailabilityZone: us-east-1c
      ImageId: ami-a4c7edb2

错误信息

模板包含错误。: 无效的模板属性或属性 [InstanceType]

谁能帮我找出为什么会出现这个错误?

谢谢

【问题讨论】:

标签: amazon-ec2 amazon-cloudformation


【解决方案1】:

如果你仔细观察,模板的缩进在InstanceCount 之后的InstanceType 处被弄乱了。如下所述修复它,您应该一切顺利。

  InstanceCount:
      Description: Number of EC2 instances (must be between 1 and 3).
      Type: Number
      Default: 1
      MinValue: 1
      MaxValue: 3
      ConstraintDescription: Must be a number between 1 and 3.
      Description: launch EC2 instances.
      Type: AWS::EC2::Instance

  InstanceType:
      Description: Launch EC2 instances.
      Type: String
      Default: t2.micro
      AllowedValues: [ t2.micro ]

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2019-11-21
    • 2020-01-11
    • 1970-01-01
    • 2018-11-25
    • 2016-11-02
    • 1970-01-01
    • 2012-12-16
    • 1970-01-01
    • 2019-03-11
    相关资源
    最近更新 更多