Reputation: 63
Is it possible to set start and stop time of cloudwatch event rules? Use Case - I want to create a rule which triggers a lambda, but I want it to run at a specific date (every 2 minutes) and disable it at another date (these date interval can span across months).
As far as I know, when we create a rule (rate (2 minutes)), it starts running immediately. I can use this approach and in the lambda I can check if the current date is same as target date and proceed with lambda execution, and disable the rule when current date is greater than end date. Although, it might work but it does not seem the right approach since lambda would be unnecessarily executing until the target date.
Is there any way I can achieve the same thing without the hack?
Upvotes: 2
Views: 1139
Reputation: 238081
Yes, you can set it to specific date only. For instance the following rule 0/2 0 28 9 ? 2020
would execute every 2 minutes on 28 Sep 2020
only:
To span across months, I think you need separate rules. For example you could define two rules to span date range 28 Sep to finish 5 Oct: 0/2 0 28-31 9 ? 2020
and 0/2 0 1-5 10 ? 2020
.
Upvotes: 3