Amplify 无法推送身份验证 - nodejs8.10

Amplify fails to push auth - nodejs8.10

我正在尝试使用 AWS Amplify 设置身份验证。

$ npm install -g @aws-amplify/cli
$ amplify --version
Scanning for plugins...
Plugin scan successful
4.13.2

授权由 运行

设置
amplify init
amplify add auth
amplify push

但是最后一个命令失败了

Resource Name: UserPoolClientLambda (AWS::Lambda::Function)
Event Type: create
Reason: The runtime parameter of nodejs8.10 is no longer supported for creating or updating AWS Lambda functions. We recommend you use the new runtime (nodejs12.x) while creating or updating functions. (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: f6d965b6-e4a6-4a0e-a380-fc07ac950266)

检查创建的文件,我发现它实际上确实使用了 nodejs8.10,但它有冲突 Amplify's documentation。我不认为手动编辑文件是一种解决方案,因为我不想将自己的代码注入到 Amplify 自动执行的操作中,并且可能在某些时候被覆盖。

我在这里遗漏或做错了什么吗?

您的 Amplify CLI 需要为 v4.10.0 或更高版本。重新运行 要更新的安装:

npm install -g @aws-amplify/cli

下次您 运行 amplify 在您的代码库中,它会建议更新节点 运行时间版本:

$ amplify --version
Scanning for plugins...
Plugin scan successful

Amplify CLI uses Lambda backed custom resources with CloudFormation to manage part of your backend resources.
In response to the Lambda Runtime support deprecation schedule
https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html
Nodejs runtime need to be updated from nodejs8.10  to nodejs10.x in the following template files:

[...]

Please test the changes in a test environment before pushing these changes to production. There might be a need to update your Lambda function source code due to the NodeJS runtime update. Please take a look at https://aws-amplify.github.io/docs/cli/lambda-node-version-update for more information

? Confirm to update the NodeJS runtime version to 10.x Yes

NodeJS runtime version updated successfully to 10.x in all the CloudFormation templates.
Make sure the template changes are pushed to the cloud by "amplify push"
4.13.4

参考:https://aws-amplify.github.io/docs/cli/lambda-node-version-update

According to AWS Lambda Runtime Support Policy, AWS Lambda deprecates Node.js runtime Node.js 8.10 on January 6th, 2020.

The Amplify CLI code base has been updated to reflect this change. Amplify CLI replaces Node.js 8.10 with Node.js 10 in the Lambda functions that it creates for you. If you use Amplify CLI version 4.10.0 and above to create new aws resources, this does not concern you.

根本原因:

  • 旧的放大版本(有 4.5 试图部署节点 8 lambda 模板)

解法:

1) npm install -g @aws-amplify/cli
2) After install click "Y" on request to update template to Node 10
3) amplify push

嗨,我相信我刚刚解决了这个问题!您需要做的是转到您的 Backend/Auth/ 目录并找到您的 *.yaml 文件

从那里搜索 AWS::Lambda::Function 服务并将运行时环境更改为 nodejs12.x

不确定为什么默认是节点 8。我在很多圈子里 运行 试图解决这个问题。