尝试在AWS上部署lambda时遇到以下错误。
Serverless Error ---------------------------------------
An error occurred: WarmUpPluginLambdaFunction - The runtime parameter of nodejs6.10 is no longer supported for creating or updating AWS Lambda functions. We recommend you use the new runtime (nodejs10.x) while creating or updating functions. (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 5211b05e-0bd4-40d7-9555-9aac489053d0).
因此,我升级了serverless-plugin-warmup的版本。现在,当我尝试在AWS上部署无服务器Lambda时,出现以下错误。该插件在节点6.10上运行正常
Serverless Error ---------------------------------------
Serverless plugin "serverless-plugin-warmup" not found. Make sure it's installed and listed in the "plugins" section of your serverless config file.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information -----------------------------
OS: linux
Node Version: 8.10.0
Serverless Version: 1.35.1
这里需要一些见识,在AWS上部署时出了什么问题。 部署脚本为
"deploy:staging": "cross-env NODE_ENV=staging sls deploy -s staging"
serverless.yml
plugins:
- serverless-plugin-warmup
- serverless-offline
- serverless-domain-manager
- serverless-log-forwarding
custom:
warmup:
schedule: 'cron(0/10 12-23 ? * MON-FRI *)'
prewarm: true
functions:
myFunction:
warmup: ${self:provider.environment.CRON}
handler: handler.myFunction
events:
- http:
path: '{model}/{id}'
method: GET
authorizer: auth
cors:
origins:
- ${self:provider.environment.APP_DOMAIN}
headers: ${self:custom.headers}
allowCredentials: true
答案 0 :(得分:1)
对于第一个错误,请尝试将其添加到根级别(与插件,函数和自定义级别相同)的serverless.yml文件中:
provider:
runtime: nodejs8.10
这应确保您的部署在适当的运行时(全局)运行。另外,您可以在lambda(与预热级别相同)下添加运行时设置,以便分别选择运行时。
对于您的第二个错误,可能是您的“升级”未顺利进行,您需要进行另一次npm安装。它告诉您已指定“ serverless-plugin-warmup”,但在node_modules中找不到它。您可能必须删除package-lock.json和/或node_modules文件夹,然后重新进行npm安装。确保在package.json(npm i serverless-plugin-warmup -D
)中列出了它。