属性验证失败:YAML 中的 AWS::SSM::Parameter [属性值 {/Tags} 与类型 {Map} 不匹配]

Had*_*ous 8 amazon-web-services aws-cloudformation aws-ssm

以下代码片段:

AWSTemplateFormatVersion: '2010-09-09'
Description: Some CloudFormation template

Resources:
  MyResourceName:
    Type: AWS::SSM::Parameter
    Properties:
      Name: myParameterName
      Type: String
      Value: "somevalue"
      Tags:
        - Key: firstTagName
          Value: firstTagValue
        - Key: secondTagName
          Value: secondTagValue
Run Code Online (Sandbox Code Playgroud)

在 CloudFormation 中生成以下错误:

属性验证失败:CloudFormation 中 AWS::SSM::Parameter 的 [属性值 {/Tags} 与类型 {Map} 不匹配]

我应该如何正确构建 Tags 属性?

Had*_*ous 10

如https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ssm-parameter.html的示例所示。Tags 属性的结构因资源而异(请参阅https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html)。对于AWS::SSM::Parameter使用键值对而不是映射:

AWSTemplateFormatVersion: '2010-09-09'
Description: Some CloudFormation template

Resources:
  MyResourceName:
    Type: AWS::SSM::Parameter
    Properties:
      Name: myParameterName
      Type: String
      Value: "somevalue"
      Tags:
        firstTagName: firstTagValue
        secondTagName: secondTagValue
Run Code Online (Sandbox Code Playgroud)

这解决了我的问题。