My goal is to run an AWS Lambda Function on a recurring schedule. However, that schedule is not compatible with CRON so CloudWatch Schedule Event Rules are not an option (to my understanding).
Specifically, I'm trying to have it run on the 5th working day. That needs to take into account weekends, holidays, and custom scheduled down-time that varies from month to month.
What is the recommended approach for running a Lambda function on a recurring schedule without actually using a CRON expression?
There are a couple workarounds that I can think of which I'll list below.
- Create a CloudWatch event that runs on every weekday. Have that trigger a Lambda that will check if it is not a holiday or scheduled downtime. If it's a valid day, it'll push a value to an SQS Queue. Once that Queue reaches 5 values in the queue, it'll empty the queue and trigger the Lambda I described above. If the Lambda fails, it'll then push to a DLQ.
- For simplicity, have the same exact thing as above but instead run it every day instead of every weekday and just perform that same check there instead.