CloudWatch scheduled events

Hi,

I am trying to create a cloudwatch lambda trigger that runs every 15 minutes. I have tried doing:

events:
5      - cloudwatchEvent:
6          event:
7            source:
8              - "aws.events"
9            detail-type:
10              - "Scheduled Event"
11            detail:
12              state:
13                - pending

but i don’t see a way of adding a schedule expression. Using the configuration below:

 events:
5      - schedule:
6          rate: rate(15 minutes)
7          enabled: false

Does not ensure it is a CloudWatch event as far as I can tell.

What I want to create is equivalent to the CloudFormation below:

15MinuteCloudWatchTrigger:
    Properties:
      Description: Scheduled CloudWatch Event Triggered every 15 minutes.
      Name: 15-Minute-CloudWatch-Trigger
      ScheduleExpression: rate(15 minutes)
      State: ENABLED
    Type: AWS::Events::Rule

Which will also have the lambda as a target.

Kindly let me know if I have to resort to CloudFormation in serverless or if I can use serverless’s more elegant syntax.

Adding the config as CloudFormation in the resource section gives me template errors due to the Lambda name not being defined.

I hope someone can give me some pointers.

nandac

1 Like

I’m trying to the similar functionality, were you able to find a way to do this via Serverless?