[英]Given an aws-lambda, how can I change the cloudwatch rule associated with it using boto3?
我看过文档 ,但是找不到如何更改预定事件。 这是serverless.yml
上的示例:
schedule_customer_processing:
handler: fetch-downloadable-client-data/adyen/schedule_customer_processing.schedule
events:
- schedule: rate(15 minutes)
使用boto3,如何以编程方式更改计划的费用?
取自我博客中的这个例子
REGULAR_SCHEDULE = 'rate(20 minutes)'
WEEKEND_SHEDULE = 'rate(1 hour)'
RULE_NAME = 'My Rule'
def reschedule_event():
"""
Cambia la planificación de la lambda, para que descanse los findes :D
"""
sched = boto3.client('events')
current = sched.describe_rule(Name=RULE_NAME)
if is_weekend() and 'minutes' in current['ScheduleExpression']:
sched.put_rule(
Name=RULE_NAME,
ScheduleExpression=WEEKEND_SCHEDULE,
)
if not is_weekend and 'hour' in current['ScheduleExpression']:
sched.put_rule(
Name=RULE_NAME,
ScheduleExpression=REGULAR_SCHEDULE,
)
调用shed.put_rule
将允许您更改事件时间表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.