【问题标题】:CloudFormation: Value of property SsmAssociations must be of type ListCloudFormation:属性 SsmAssociations 的值必须是 List 类型
【发布时间】:2019-04-22 05:27:08
【问题描述】:

我正在为一个 EC2 实例创建一个 CloudFormation 模板,我将使用它来管理我已经在我的 VPC 中部署的 Active Directory 服务器。我在定义 AWS::EC2::Instance 资源时遇到问题。这可能是 YAML 语法问题,但我无法看到问题。

创建堆栈时,它会回滚并出现错误“属性 SsmAssociations 的值必须是列表类型”。文档在示例方面有些稀疏。 Amazon EC2 Instance SsmAssociations

这是有问题的 YAML 的 sn-p:

Resources: 
  EC2Instance:
    Type: AWS::EC2::Instance
    Properties:
      IamInstanceProfile: !Ref InstanceProfile
      SsmAssociations:
        DocumentName: !Ref InstanceProfile
        AssociationParameters:
          -
            Key: "directoryId"
            Value: 
              - 
                Fn::ImportValue:
                  Fn::Join:
                  - ''
                  - - !Ref ADStackName
                    - '-'
                    - 'DirectoryId'
          - 
            Key: "directoryName"
            Value: 
              - 
                Fn::ImportValue:
                  Fn::Join:
                  - ''
                  - - !Ref ADStackName
                    - '-'
                    - 'DirectoryName'
          - 
            Key: "dnsIpAddresses"
            Value:
              - 
                Fn::ImportValue:
                  Fn::Join:
                  - ''
                  - - !Ref ADStackName
                    - '-'
                    - 'ADServer1PrivateIP'
              - 
                Fn::ImportValue:
                  Fn::Join:
                  - ''
                  - - !Ref ADStackName
                    - '-'
                    - 'ADServer2PrivateIP'
      KeyName: !Ref EC2KeyPair 

感谢您的帮助。

【问题讨论】:

    标签: amazon-web-services amazon-ec2 yaml amazon-cloudformation


    【解决方案1】:

    根据AWS::EC2::Instance的文档,说明SsmAssociations

    类型:Amazon EC2 实例 SsmAssociations 列表。

    (这也是您的错误消息所述)。但是,在您的 YAML 声明中,您提供了一个 SsmAssociations。尝试将其更改为以下内容:

    Resources: 
      EC2Instance:
        Type: AWS::EC2::Instance
        Properties:
          IamInstanceProfile: !Ref InstanceProfile
          SsmAssociations:
            # Notice the addition of the "-" on the line below to declare a yaml list
            - 
              DocumentName: !Ref InstanceProfile
              AssociationParameters:
              # add the rest of the declaration
    

    【讨论】:

    • 眼光不错,答对了!感谢您的快速解决方案。
    猜你喜欢
    • 2020-11-04
    • 1970-01-01
    • 2020-09-24
    • 2023-03-30
    • 2021-12-05
    • 2020-03-25
    • 1970-01-01
    • 2020-07-14
    • 2021-11-23
    相关资源
    最近更新 更多