You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过EventBridge Scheduler带路径调用AWS Lambda函数?

解决方案

你的Nuxt3应用部署为Lambda函数时,依赖API Gateway格式的事件来识别请求路径。因此需要在EventBridge Scheduler的Input字段中构造对应格式的JSON,明确指定path参数。

修改后的CloudFormation模板Input部分如下:

LambdaScheduler:
  Type: AWS::Scheduler::Schedule
  Properties:
    FlexibleTimeWindow:
      MaximumWindowInMinutes: 5
      Mode: FLEXIBLE
    Name: lambda-schedule
    ScheduleExpression: cron(0/15 * * * ? *)
    State: ENABLED
    Target:
      Arn: !GetAtt HogeLambdaFunction.Arn
      Input: |-
        {
          "requestContext": {
            "http": {
              "method": "GET"
            }
          },
          "path": "/api/v1/hoge",
          "headers": {},
          "body": null
        }
      RoleArn: !GetAtt SchedulerRole.Arn
      DeadLetterConfig:
        Arn: !GetAtt DeadLetterQueue.Arn

关键说明

  • Nuxt3的Lambda适配器通过API Gateway事件结构解析请求路径、方法等信息,必须确保Input中包含path字段。
  • 若接口需要POST等其他请求方法,修改requestContext.http.method的值即可。
  • 如果需要传递请求体,将body字段替换为对应的JSON字符串(注意格式转义)。

内容的提问来源于stack exchange,提问作者ahoo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 19:52:13