Serverless 中的 lambda 函数在容器中时是否仍可以设置超时时间

问题描述 投票:0回答:1

在普通 lambda 中,可以直接在 serverless.yml 中设置超时

例如

functions:
  my_function:
    handler: handler.my_function
    timeout: 60

但是,当我使用容器映像时,这似乎会丢失,并且 AWS 使用默认值 6 秒。这是示例代码:

functions:
  my_function:
    image:
      name: appimage
      command:
        - handler.my_function
    timeout: 60

我做错了什么吗?我当然可以在 AWS 控制台上手动设置它,但最好将所有内容都放在 yml 中

aws-lambda serverless-framework
1个回答
0
投票

为什么是的,是的,你可以。 在您的

serverless.yml
中添加以下内容: 来自文档:

provider:
  runtime: nodejsXX.x
  # Default timeout for functions (default: 6 seconds)
  # Note: API Gateway has a maximum timeout of 30 seconds
  timeout: 10

6 秒是默认超时,最大值为 30,因此只需在提供程序块下添加超时即可完成设置!你很接近!

© www.soinside.com 2019 - 2024. All rights reserved.