How to set a serverless cron job to run after 10 days from first deploy and than to run every day

Viewed 29

I need some help setting up the schedule for a lambda function that I deploy with serverless framework. It should start running daily, but only 10 days after it has been deployed.

Is this possible?

functions:
  prerequisites:
    handler: prerequisites.prerequisites
  keyRotation:
    handler: iamKeyRotation.main
    events:
      - schedule: cron(0 6 * * ? *)

I just set the function to run every day.

1 Answers

There isn't a way in cron to define a pattern that is daily but has a 10 day wait built in. From your comments it seems like you're deploying to multiple accounts and don't want to touch it twice.

My recommendation would be to write a "deployer" lambda that takes in some configuration like account number, date, etc., and deploys the lambda when needed on the day it's needed with a daily cron. Then you just update the configuration to reference when a specific account needs the lambda to be deployed.

Related