从计划程序调用 Lambda GET 端点

huangapple go评论69阅读模式
英文:

Calling a Lambda GET endpoint from a scheduler

问题

我想每12小时对我的Lambda的特定端点进行GET调用。

我可以使用哪个AWS服务来实现这个目标?

我已经尝试过Amazon EventBridge,但是我找不到调用Lambda特定端点的方法(是否有方法可以实现?)。

我还尝试过Route53 Health Check(可以指定端点,这很好),但是无法将调用间隔设置为12小时,而且我需要提供3个健康检查区域(我只需要1个)。

有什么建议吗?

英文:

I want to make a GET call to a specific endpoint in my Lambda, every 12 hours.

What AWS service can I use for that?

I have tried Amazon EventBridge, however, I cannot find a way to call a specific endpoint in my lambda (is there a way?).

I have also tried Route53 Health Check (where I can specify an endpoint and that's great), but, the call intervals cannot be set to 12 hours, plus, I need to provide 3 health checker regions (I only need 1).

Any ideas?

答案1

得分: 1

在AWS中可以通过以下步骤来实现这一点。

  1. 创建目标Lambda函数。我们称其为Lambda1。

  2. 设置一个API Gateway端点,配置为GET请求,触发Lambda1。现在可以使用GET请求来调用Lambda1。如果你不知道如何设置API Gateway,请参考此文档中的说明。参见主题配置Amazon API Gateway以调用Lambda函数:https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/usecases/creating_lambda_apigateway

  3. 现在,您可以通过发送GET请求来调用Lambda。我建议创建第二个Lambda函数,该函数发送GET请求以调用Lambda1。您可以使用CRON表达式每12小时调度此操作。在Lambda应用逻辑中,您可以处理Lambda1返回的数据以满足业务需求。

更新
您可以通过配置CRON表达式来调用第二个调用Lambda1的Lambda。有关如何执行此操作的信息,请参见:

创建定期事件以调用Lambda函数

英文:

One way this can be done in AWS is by following these steps.

  1. Create your target Lambda Function. Lets call it Lambda1.

  2. Setup an API Gateway endpoint that is configured as a GET that invokes Lambda1. Now Lamba1 can be invoked using a GET request. If you do not know how to setup an API Gateway, see the instructions in this doc. See the topic Configure Amazon API Gateway to invoke the Lambda function: https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/usecases/creating_lambda_apigateway

  3. Now you can invoke the Lambda by sending a GET request. I would look at creating a second Lambda function that sends a GET Request to invoke Lambda1. You can schedule this using CRON expressions every 12 hours. In your Lambda app logic, you can process the data returned by Lambda1 to meet your business requirements.

UPDATE
You can invoke the 2nd Lambda that invokes Lambda1 by configuring a CRON Expression. For information how to do this -- see:

Creating scheduled events to invoke Lambda functions

huangapple
  • 本文由 发表于 2023年5月17日 18:54:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76271314.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定