延迟几个小时调用lambda函数 [英] invoke lambda function with hours delay

查看:79
本文介绍了延迟几个小时调用lambda函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出5小时后调用aws lambda函数的最佳方法是什么.我还有另一个lambda函数,该函数将发出多个检索作业以从aws冰川中抓取项目,而且我需要一种解决方案,以便在检索到每个项目后在每个项目上运行另一个lambda函数,大约需要5个小时.我当时正在考虑使用sns,但想知道是否还有其他方法可以使用它.任何输入表示赞赏.

I am trying to figure out what is the best approach to invoke an aws lambda function 5 hours later. I have another lambda function that would issue multiple retrieval jobs to grab items out of aws glacier, and I need a solution to run another lambda function on each of the items once they are retrieved, which is about 5 hours. I was thinking about using sns but was wondering if there are other approaches to this. any input is appreciated.

推荐答案

除了使用CloudWatch外,您遇到的另一种有趣的方法是使用

Besides using CloudWatch, another interesting approach in your case would be to use AWS Step Functions:

  1. 要么使用

  2. 或者您可以在

  3. Or you can use a separate Lambda function in a task state combined with a choice state which checks in a loop if the other function should run:

    {
      "Comment": "A state machine that submits a Job to AWS Batch and monitors the Job until it completes.",
      "StartAt": "Wait X Seconds",
      "States": {
        "Wait X Seconds": {
          "Type": "Wait",
          "SecondsPath": "$.wait_time",
          "Next": "Get Job Status"
        },
        "Get Job Status": {
          "Type": "Task",
          "Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:CheckJob",
          "Next": "Job Complete?"
        },
        "Job Complete?": {
          "Type": "Choice",
          "Choices": [
            {
              "Variable": "$.status",
              "StringEquals": "RUNNING",
              "Next": "Wait X Seconds"
            },
            {
              "Variable": "$.status",
              "StringEquals": "SUCCEEDED",
              "Next": "Do Job"
            }
          ],
          "Default": "Wait X Seconds"
        },
        "Do Job": {
          "Type": "Task",
          "Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:DoJob",
          "End": true
        }
      } 
    }
    

  4. 这篇关于延迟几个小时调用lambda函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆