【发布时间】:2021-10-11 13:30:57
【问题描述】:
我有一个 lambda 函数,用于从 API 获取数据。在我的 lambda 函数中,我使用当前时间 - 1 小时。而不是这个,我想使用当前时间 - [最后成功执行时间] 用于该功能。这可能吗?
from_time = ""
if response["executions"]:
start_time = response["executions"][0]["startDate"]
week_ago = datetime.now() - timedelta(days=7)
week_ago = week_ago.replace(tzinfo=start_time.tzinfo)
if start_time > week_ago:
from_time = get_utc_time(start_time)
else:
from_time = get_utc_time(datetime.now() - timedelta(hours=1))
logger.info(f"Last successful execution time in UTC: {from_time}")
我遇到了这个https://docs.aws.amazon.com/cli/latest/reference/stepfunctions/get-execution-history.html
但我不明白如何在我的情况下使用这个get-execution-history(阶梯函数内的地形化 lambda 函数)
【问题讨论】:
-
也许您可以将值保存在文件中并在下次执行时读取它。
-
如何获取、保存和阅读?这就是问题:P @furas
-
使用 AWS SDK Step Function Class 及其方法,boto3.amazonaws.com/v1/documentation/api/latest/reference/… 但是是的,我会说你应该存储执行参考,或者某处的时间
标签: python amazon-web-services lambda terraform aws-step-functions