如何使用CloudFormation模板创建CloudWatch事件?

9

我使用CloudWatch定时事件来触发我的Lambda函数,以便在特定时间间隔后进行操作。我想使用CloudFormation模板将此规则添加到CloudWatch中。我已经阅读了CloudFormation模板文档,但无法找到使用CloudFormation模板配置事件的方法。请问有人可以建议如何使用CloudFormation模板实现吗。

我使用以下模板。

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "Provision environment specific",
  "Resources": {
    "lambdaScheduler": {
      "Type": "AWS::CloudWatch::Event",
      "Properties": {
        "detail-type": "Scheduled Event",
        "source": "aws.events",
        "name": "TEST_EVENT_10_MINS_RULE",
        "schedule-expression": "rate(5 minutes)"
      }
    }
  }
}

当我使用AWS CLI验证模板时,出现了A client error (ValidationError) occurred when calling the ValidateTemplate operation: Template format error: Unrecognized resource type: AWS::CloudWatch::Event错误信息。

3个回答


5

0
你尝试过在CloudFormation设计师中布局你的设计吗?它只为每个元素创建存根代码,但它验证了整体设计。然后,你需要将概要代码转移到编辑器中进行实际工作,但它应该避免你引用的错误。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接