10
votes

I have a event in CloudWatch, which is triggered once a day. Is there a way to trigger the event manually (for testing purposes)?

...I realize I can increase the frequency of the event's triggering schedule.

3
triggers what? if it is lambda then the solution might be easier.Lamanus
I want to trigger the event itself to ensure the permissions granted to it and the wiring to the thing it calls (a step function) is correct. I’ve already run the step function independently to test its flow.Adam

3 Answers

10
votes

If you have a cloudwatch alarm set up, using the AWS CLI you can, for testing purposes, set the alarm state of that alarm:

aws cloudwatch set-alarm-state --alarm-name "myalarm" --state-value ALARM --state-reason "testing purposes"

see the docs here

Alternatively you can put a custom event, also using the CLI or the SDKs

4
votes

Another solution I found is to disable then re-enable the rule:

aws events disable-rule --name "my_scheduled_rule"
aws events enable-rule --name "my_scheduled_rule"

Perhaps not the best route but an option...

0
votes

I haven't found (and I don't think it is possible) to trigger a scheduled trigger manually. But as danimal mentions you can put a custom event to trigger it.

# update your rule to trigger on a dummy-event source
# put-rule updates a rule if it exists or creates a new one if it doesn't
aws events put-rule --name "my-rule" --event-pattern "{\"source\":[\"karlanka\"]}"

# send an event with the same dummy source to trigger the rule
# Detail and DetailType are required but not used
aws events put-events --entries '[{"Source":"karlanka","DetailType":"X","Detail":"{}"}]'

# then change the rule back to your schedule
aws events put-rule --name "my-rule" --schedule-expression "rate(12 hours)"