How to create cloudwatch event using cloudformation template?

Chetan Shirke picture Chetan Shirke · Mar 1, 2016 · Viewed 7.6k times · Source

I am using cloudwatch scheduled event to trigger my lambda function after specific time interval. I would like to use cloud-formation template to add this rule in cloudwatch. I have gone through cloudformation templates documentation but I am not able to find out way to configure events using cloud formation template. Can anyone please suggest how to implement it using cloud formation template.

I am using below template.

{
  "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)"
      }
    }
  }
}

I am getting A client error (ValidationError) occurred when calling the ValidateTemplate operation: Template format error: Unrecognized resource type: AWS::CloudWatch::Event error message when I validate it using aws cli.

Answer