Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I validate an AWS cron expression in Java 8 without creating the AWS resource?

I'm trying to find a way to validate a cron expression in Java 8 that conforms with AWS requirements without having to create the CloudWatch resource. The way I'm currently validating my cron expression is by trying to create the CW resource and then handling the ParseException thrown. However, I'd like to know before deploying the resource if the cron expression entered by the user is a valid AWS cron expression.

Does Amazon conform to a cron expression standard? I have been reading AWS documentation to see if the requirements for Amazon cron expressions follow a standard (Unix, Quartz, etc) but there are enough little differences that I haven't been able to confirm that they do. Maybe I don't know enough about cron, but it seems like AWS has their own standard for cron expressions. However, I don't see that they have provided their own cron expression validator.

like image 727
jlsegb Avatar asked Dec 18 '19 20:12

jlsegb


1 Answers

I would just create some regex expressions for validation if that is all you are looking for. As for does it adhere to standard cron/crontab specs, the answer is no. AWS cron has six fields vs the five that cron/crontab has. Plus the AWS doesn't have @ operator and many other things are missing or different.

This is the best documentation that I have seen for the AWS cron : https://docs.aws.amazon.com/glue/latest/dg/monitor-data-warehouse-schedule.html

like image 174
pitchblack408 Avatar answered Oct 03 '22 03:10

pitchblack408