我知道我可以通过AWS控制台创建一个预定的云监控活动:
有没有办法在云形成模板中声明类似的事件?
发布于 2020-07-14 03:16:25
下面是在cloudwatch中创建定时事件的示例,它创建了一个规则,每10分钟调用一次指定的Lambda函数。PermissionForEventsToInvokeLambda资源授予EventBridge调用相关函数的权限。
"ScheduledRule": {
"Type": "AWS::Events::Rule",
"Properties": {
"Description": "ScheduledRule",
"ScheduleExpression": "rate(10 minutes)",
"State": "ENABLED",
"Targets": [{
"Arn": { "Fn::GetAtt": ["LambdaFunction", "Arn"] },
"Id": "TargetFunctionV1"
}]
}
},
"PermissionForEventsToInvokeLambda": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"FunctionName": { "Ref": "LambdaFunction" },
"Action": "lambda:InvokeFunction",
"Principal": "events.amazonaws.com",
"SourceArn": { "Fn::GetAtt": ["ScheduledRule", "Arn"] }
}
}该示例引用自AWS官方文档。
发布于 2018-08-22 23:35:45
是的,这是可能的。
AWS::Events::Rule资源创建与传入的Amazon CloudWatch Events (CloudWatch Events)事件相匹配的规则,并将其路由到一个或多个目标进行处理。
以下是示例CloudFormation代码片段:
Type: AWS::Events::Rule
Properties:
Description: String
EventPattern: JSON object
Name: String
ScheduleExpression: String
State: String
Targets:
- Target如果你有更多的问题,这是official documentation。
发布于 2018-08-22 23:48:20
是的,可以通过@bhalothia分享。请找一篇文章,让你深入了解它。
实际实施:
http://marcelog.github.io/articles/serverless_cloudwatch_event_cloudformation_template.html
细节渐变:
我希望这对你有帮助。
https://stackoverflow.com/questions/51969953
复制相似问题