Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import boto3
from botocore.exceptions import ClientError
# from boto3 import ValidationException
import uuid
clt = boto3.client("events")
rule_name = f"cronValidationTestRule-{uuid.uuid1()}"
# TODO: accept input from STDIN or argv
cron_string = "cron(-0 8 ? * MON-FRI *)"
try:
print("Testing cron rule on AWS: ", cron_string)
clt.put_rule(
Name=rule_name,
ScheduleExpression=cron_string,
State="DISABLED",
Description="This is a test rule. Delete me at will!",
)
print("Valid cron expression. Feel free to use it.")
clt.delete_rule(Name="testRule")
except ClientError as error:
print(
"\n** Invalid cron expression! Try another. **\n\nhttps://docs.aws.amazon.com/systems-manager/latest/userguide/reference-cron-and-rate-expressions.html\n\n",
error,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment