无服务器框架:UpdateFunctionCode 操作的请求大小必须小于 69905067 字节。

19

我正在使用上传压缩文件的包,如:

frameworkVersion: "=1.27.3"

service: recipes

provider:
  name: aws
  endpointType: REGIONAL
  runtime: python3.6
  stage: dev
  region: eu-central-1
  memorySize: 512
  deploymentBucket:
    name: dfki-meta
  versionFunctions: false
  stackTags:
    Project: DFKIAPP
  # Allows updates to all resources except deleting/replacing EC2 instances
  stackPolicy:
    - Effect: Allow
      Principal: "*"
      Action: "Update:*"
      Resource: "*"
    - Effect: Deny
      Principal: "*"
      Action:
        - Update: Replace
        - Update: Delete
      Resource: "*"
      Condition:
        StringEquals:
          ResourceType:
            - AWS::EC2::Instance
  # Access to RDS and S3 Bucket
  iamRoleStatements:
    -  Effect: "Allow"
       Action: "s3:ListBucket"
       Resource: "*"


package:
  individually: true

functions:
#  get_recipes:
#    handler: handler.get_recipes
#    module: recipes_crud
#    package:
#      individually: true
#    timeout: 30
#    events:
#      - http:
#          path: recipes
#          method: get
#          request:
#            parameters:
#              querystring:
#                persona: true

  get_recommendation:
    handler: handler.get_recommendation
    module: recipes_ml
    package:
      artifact: zipped_dir.zip
    timeout: 30
    events:
      - http:
          path: recipes/{id}
          method: get
          request:
            parameters:
              paths:
                id: true
              querystring:
                schaerfe_def: true
                saettig_def: true
                erfahrung_def: true
                schaerfe_wunsch: true
                saettig_wunsch: true
                erfahrung_wunsch: true
                gericht_wunsch: true
                stimmung_wunsch: true

无法理解此错误,52.18不在69905067字节以下吗?

(node:50928) ExperimentalWarning: The fs.promises API is experimental
Serverless: Packaging function: get_recommendation...
Serverless: Uploading function: get_recommendation (52.18 MB)...

  Serverless Error ---------------------------------------

  Request must be smaller than 69905067 bytes for the UpdateFunctionCode operation

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           10.1.0
     Serverless Version:     1.27.3

2
如果您删除堆栈并重新部署,则可以正常工作。部署单个超大函数无法正常工作。我仍在努力理解原因。 - 3nomis
3个回答

11
似乎这只是在使用 Serverless 上传单个 Lambda 函数时发生的问题,但如果您不提供 --function 参数并部署整个堆栈,则可以正常工作!!!

7
根据文档,包的大小应该低于50MB。这里是文档链接: https://docs.aws.amazon.com/lambda/latest/dg/limits.html enter image description here 引用一篇博客文章,其中提到20MB的额外空间可能是为了考虑AWS API请求开销(例如zip文件数据的base64编码)。目前50MB限制还算准确。但我们还没有被击败。文章链接如下: this blog post

1
这很奇怪。我的压缩的 Lambda 包大小为 66 MB。如果我尝试使用 CLI 更新函数,就会出现错误。但是如果我将其上传到 S3 上,我可以通过在 AWS 控制台上提供 S3 上的文件路径来更新函数。 - RodrikTheReader
这是非常有趣的信息,我从未尝试过。但是肯定会遇到限制,我想说。 - dege
是的,如果解压后的数据大于250 MB,无论如何我仍然会遇到限制。但在CLI上,即使未解压缩的文件大小小于250 MB,如果zip文件大于50 MB,它也不允许我更新函数。 - RodrikTheReader

0
如果只需要更新配置,应该使用--update-config或-u选项。这将仅推送Lambda级别的配置更改,例如处理程序、超时时间或内存大小。
serverless deploy function -f functionName --update-config

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接