Naushad Qamar
Naushad Qamar

Reputation: 133

how to add multiple targets in serverless.yml schedule event

I am trying to call multiple lambda from Cloudwatch event , I am not sure how to add other target lambda using serverless.yml. below code add only add one target but I want multiple , from console I can add multiple targets where I triggered different Lambda

 - schedule:
          name: lambda-warmer-scheduler
          description: 'scheduler to warmup lambdas '
          rate: rate(2 minutes)

From Console I can add multiple targets , how can we do it using yml enter image description here

Upvotes: 0

Views: 1865

Answers (1)

Quentin Hayot
Quentin Hayot

Reputation: 7876

Edit:
I now understand that your goal is to create a lambda warming system.
You can use the very good serverless-plugin-warmup for this. It does exactly what you are trying to achieve, in the way you are trying to do it.


The events property in your function's declaration in serverless.yml is a list. You can add several events that will trigger your lambda:

functions:
  yourFunction:
    handler: yourFunction.handler
      events:
        - schedule:
              name: lambda-warmer-scheduler
              description: 'scheduler to warmup lambdas '
              rate: rate(2 minutes)
        - schedule:
              name: lambda-warmer-scheduler-2
              description: 'scheduler to warmup lambdas '
              rate: rate(5 minutes)
        - schedule:
              name: lambda-warmer-scheduler-3
              description: 'scheduler to warmup lambdas '
              rate: rate(5 hours)

Each item on the events property will create an event (in this example only schedules but you can mix different event sources, like schedules, http, streams...).

Upvotes: 1

Related Questions