CloudFormation AWS :: Events :: Rule:遇到不受支持的属性ID

时间:2018-12-27 08:38:31

标签: amazon-web-services lambda amazon-cloudformation amazon-cloudwatch

尝试使用CloudFormation创建AWS Lambda函数。当创建调度规则作为AWS Lambda函数的目标时,出现以下错误:

  

Lambda函数需要目标

我的模板如下:

"ScheduledRule": {
    "Type": "AWS::Events::Rule",
    "Properties": {
        "Description": "ScheduledRule",
        "ScheduleExpression": "rate(10 minutes)",
        "State": "ENABLED",
        "Targets": [{
            "Arn": {
                "Fn::GetAtt": ["LambdaFunction", "Arn"]
            }

        }],

        "Id": "id",
        "RoleArn": {
            "Fn::GetAtt": [
                "LambdaFunction",
                "Arn"
            ]
        }
    }
},

1 个答案:

答案 0 :(得分:1)

事件规则的嵌套是错误的。在模板IdRoleArn中是Properties的子级,而它们应该是目标的子级。正确的模板为:

"ScheduledRule": {
    "Type": "AWS::Events::Rule",
    "Properties": {
        "Description": "ScheduledRule",
        "ScheduleExpression": "rate(10 minutes)",
        "State": "ENABLED",
        "Targets": [{
            "Arn": {
                "Fn::GetAtt": ["LambdaFunction", "Arn"]
            },
            "Id": "id",
            "RoleArn": {
                "Fn::GetAtt": [
                    "LambdaFunction",
                    "Arn"
                ]
            }
        }]
    }
},