【问题标题】:Cannot determine what property value is empty?无法确定哪个属性值为空?
【发布时间】:2020-07-19 05:54:55
【问题描述】:

使用以下模板(预先存在的嵌套堆栈的一部分)运行 AWS CloudFormation 时,我遇到“属性值不能为空”的错误。对于我尝试为其创建 CloudWatch 警报的两个 lambda 项。我试图将它作为嵌套堆栈的一部分以及模板本身运行,但无济于事。任何人都可以提供任何见解吗?

{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "Creation of CloudWatch Alarms",
    "Resources": {
        "CLFirstLambdaAlarm": {
            "Type": "AWS::CloudWatch::Alarm",
            "Properties": {
                "AlarmName": "CLFirstLambdaErrors",
                "AlarmDescription": "Alarms when an error occurs on the first lambda",
                "AlarmActions": [{ "Ref": "AlarmNotificationTopic" }],
                "MetricName": "Errors",
                "Namespace": "AWS/Lambda",
                "Dimensions": [{
                        "Name": "first-lambda"
                    },
                    {
                        "Value": { "Fn::ImportValue": "CLFirstLambda" }
                    }
                ],
                "ComparisonOperator": "GreaterThanOrEqualToThreshold",
                "EvaluationPeriods": "1",
                "Period": "60",
                "Unit": "Count",
                "Statistic": "Sum",
                "Threshold": "1",
                "TreatMissingData": "notBreaching"
                    }
        },
        "CLSecondLambdaAlarm": {
            "Type": "AWS::CloudWatch::Alarm",
            "Properties": {
                "AlarmName": "CLSecondLambdaErrors",
                "AlarmDescription": "Alarms when an error occurs on the second lambda",
                "AlarmActions": [{ "Ref": "AlarmNotificationTopic" }],
                "MetricName": "Errors",
                "Namespace": "AWS/Lambda",
                "Dimensions": [{
                        "Name": "second-lambda"
                    },
                    {
                        "Value": { "Fn::ImportValue": "CLSecondLambda" }
                    }
                ],
                "ComparisonOperator": "GreaterThanOrEqualToThreshold",
                "EvaluationPeriods": "1",
                "Period": "60",
                "Unit": "Count",
                "Statistic": "Sum",
                "Threshold": "1",
                "TreatMissingData": "notBreaching"
            }
        },
        "AlarmNotificationTopic": {
            "Type": "AWS::SNS::Topic",
            "Properties": {
                "TopicName": "cl-alarm-topic",
                "Subscription": [{
                "Endpoint": "me@domain.com",
                "Protocol": "email"
                }]
            }
        }
    },
    "Outputs": {
        "AlarmNotificationTopicArn": {
            "Description": "ARN of AlarmNotificationTopic",
            "Value": { "Ref" : "AlarmNotificationTopic" },
            "Export": { "Name" : "AlarmNotificationTopic" }
        }
    }
}

【问题讨论】:

  • 你应该能够至少为哪个资源失败?

标签: json amazon-web-services amazon-cloudformation


【解决方案1】:

CloudFormation Linter 提供更详细的错误消息:

E3003 Property Value missing at Resources/CLFirstLambdaAlarm/Properties/Dimensions/0
template.json:13:30

E3003 Property Name missing at Resources/CLFirstLambdaAlarm/Properties/Dimensions/1
template.json:16:19

E3003 Property Value missing at Resources/CLSecondLambdaAlarm/Properties/Dimensions/0
template.json:37:30

E3003 Property Name missing at Resources/CLSecondLambdaAlarm/Properties/Dimensions/1
template.json:40:19

AWS::CloudWatch::Alarm

AWS::CloudWatch::Alarm.Dimension


试试这些AWS::CloudWatch::Alarm.Dimensions 属性:

              "Dimensions": [{
                      "Name": "first-lambda",
                      "Value": { "Fn::ImportValue": "CLFirstLambda" }
                  }
              ],


              "Dimensions": [{
                      "Name": "second-lambda",
                      "Value": { "Fn::ImportValue": "CLSecondLambda" }
                  }
              ],

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-11
    • 2013-04-24
    • 1970-01-01
    • 1970-01-01
    • 2014-11-20
    • 2016-01-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多