首页 > 解决方案 > AWS CloudFormation 错误“属性 AlarmActions 的值必须是字符串列表类型”

问题描述

我正在尝试更新我的 cf 堆栈并在部署时遇到以下错误:'属性 AlarmActions 的值必须是字符串列表类型'

这是属性 AlarmActions:

 AlarmActions:
                - !Ref SparksTeamSNSTopic
                - !If
                    - CreateProdResources
                    - - !Ref SparksProdAlarmSNSTopic
                      - !ImportValue
                          'Fn::Sub': '${Environment}-BMCMajorAlarmTopic'
                    - - !Ref 'AWS::NoValue'                   

标签: amazon-web-servicesyamlamazon-cloudformationdevops

解决方案


根据 AWS文档AlarmActions属性必须包含值,作为字符串列表。所以如果它是JSON ,你应该有这样的东西:

"AlarmActions":[
      {"Ref":"ARN of something"},
      {"Ref":"ARN of something"}           
]

但既然你使用过 YAML,你应该有这样的东西:

AlarmActions:
      - !Split [",", !Ref SparksTeamSNSTopic]  <-- make sure SparksTeamSNSTopic contains a list of strings; hence this will split it by comma 

您可以定义SparksTeamSNSTopic

"SparksTeamSNSTopic" : ["topicarn1", "topicarn2"]

推荐阅读