Skip to content

Instantly share code, notes, and snippets.

@dpritchett
Last active June 21, 2019 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpritchett/dc175f83261c34caaad4df32384921a9 to your computer and use it in GitHub Desktop.
Save dpritchett/dc175f83261c34caaad4df32384921a9 to your computer and use it in GitHub Desktop.
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