Last active
June 21, 2019 19:48
-
-
Save dpritchett/dc175f83261c34caaad4df32384921a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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