尝试使用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"
]
}
}
},
答案 0 :(得分:1)
事件规则的嵌套是错误的。在模板Id
和RoleArn
中是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"
]
}
}]
}
},