我见过docs,但是找不到如何更改预定事件。这是serverless.yml
上的示例:
schedule_customer_processing:
handler: fetch-downloadable-client-data/adyen/schedule_customer_processing.schedule
events:
- schedule: rate(15 minutes)
使用boto3,如何以编程方式更改计划的费用?
答案 0 :(得分:1)
根据我的blog
中的示例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
将允许您更改事件时间表。