import json from datetime import datetime, timedelta import boto3 clusters = [ "1311285575352848384", "1379661944593934067", "1379661944581754072", "1379661944581034066", "1379661944581034065", "1379661944581004072", "1379661944581004071", "1379661944579474076", "1363424513567494144", ] def lambda_handler(event, context): step = 60000 start_ts = int((datetime.now() - timedelta(minutes=10)).timestamp() * 1000) // step * step stop_ts = start_ts + step print(start_ts, stop_ts) client = boto3.client("lambda") for idx, cluster in enumerate(clusters): client.invoke( FunctionName="clinic-log-test", InvocationType="Event", Payload=json.dumps( { "task_id": start_ts + idx, "kwargs": { "cluster": cluster, "start_ts": start_ts, "stop_ts": stop_ts, }, } ), )