Cloud Confusing

Explaining hosting, AWS, Wordpress, static sites, and all manner of cloud solutions.

Ever wonder: when does AWS CloudWatch run rate events? I had this same question when I started using CloudWatch as a trigger for the Lambda job that backups my Lightsail instances.

Basically I had created a few events an told them to run once a day. That’s great, but when would that be? Rate events are not like cron events where you set a time and they run at (or very close to) when you specify. After all, you are simply saying “run once a day” not “run exactly at 01:14 UTC every day.”

Note: All CloudWatch events can be granular down to the minute and operate on UTC time (UTC+0). 

In CloudWatch time-based events can be run in a manner of ways, but generally you are working with a Fixed Rate of (aka Rate Expression) or a Cron Expression.

A fixed rate, known as a rate expression, event is easy to define but less precise than a cron event. Cron jobs can run at a certain time of a certain day, week, month, or year. Rate events simply run on a reoccurring interval.

Amazon has extensive instructions for scheduling events, but nothing should surprise you. A cron job looks like the word “cron” followed by 6 required fields: --schedule-expression "cron(0 11 * * ? *)" for example. This would run an event at 11 am UTC every day. The asterisks are wildcards that include all values and the question mark means “nothing specified” or “I don’t care”. In this case, the parameter asks “what day of the week?” and the question mark responds with an inclusive wildcards which neither specifics Mon-Sun or 1-7.

Or course cron jobs can do rates as well. If you wanted something to run every 5 minutes during weekdays you’d simply create a job that goes: cron 0/5 * ? * MON-FRI *. But a rate expression would be much simpler with just: rate(5 minutes).

When Do Rate Events Run?

So, back to the original question, when do AWS rate events run? They run when they are created! If you create an event at 4pm and tell it to run once a day, it will run at 4pm. A bit anticlimactic maybe, but it makes total sense right?

June 10th, 2019

Posted In: AWS

Tags:


© Cloudconfusing.com 2019 | Privacy Policy | About