【问题标题】:How to create cloudwatch event using cloudformation template?如何使用 cloudformation 模板创建 cloudwatch 事件?
【发布时间】:2016-06-13 10:42:39
【问题描述】:

我正在使用 cloudwatch 预定事件在特定时间间隔后触发我的 lambda 函数。我想使用 cloud-formation 模板在 cloudwatch 中添加此规则。我已经浏览了 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 错误消息。

【问题讨论】:

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


    【解决方案1】:

    【讨论】:

      【解决方案2】:

      我很确定 CloudWatch 事件尚未通过 CloudFormation API 公开。 AWS 中的新功能与 CloudFormation 团队实施/公开的新功能之间通常存在一些滞后。

      这是当前可通过 CloudFormation 获得的资源列表。 http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html

      正如我们所见,Cloudwatch 命名空间中只有一种资源。

      【讨论】:

        【解决方案3】:

        您是否尝试过在 CloudFormation 设计器中布置您的设计?它只为每个元素创建存根代码,但它验证了整体设计。然后,您必须将大纲代码传输到编辑器以完成实际工作,但它应该避免您引用的错误。

        【讨论】:

          猜你喜欢
          • 2020-06-23
          • 2019-01-28
          • 2020-11-27
          • 1970-01-01
          • 2022-11-03
          • 2019-02-02
          • 1970-01-01
          • 1970-01-01
          • 2015-07-21
          相关资源
          最近更新 更多