我在CloudWatch中有一个事件,每天触发一次。有没有一种方法可以手动触发事件(出于测试目的)?
...我意识到我可以增加事件触发时间表的频率。
答案 0 :(得分:3)
我发现的另一个解决方案是禁用然后重新启用规则:
aws events disable-rule --name "my_scheduled_rule"
aws events enable-rule --name "my_scheduled_rule"
也许不是最好的路线,而是一种选择...
答案 1 :(得分:2)
如果您设置了云监视警报,则可以使用AWS CLI为测试目的设置该警报的警报状态:
aws cloudwatch set-alarm-state --alarm-name "myalarm" --state-value ALARM --state-reason "testing purposes"
请参见docs here
或者,也可以使用CLI或SDK,put a custom event
答案 2 :(得分:0)
我还没有发现(而且我认为不可能)手动触发计划的触发器。但是如动物般的提及,您可以放置一个自定义事件来触发它。
# 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)"