Search code examples
amazon-web-servicesaws-amplify

Amplify fails to push auth - nodejs8.10


I'm trying to setup auth with AWS Amplify.

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

Auth was setup by running

amplify init
amplify add auth
amplify push

The last command however fails with

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)

Checking the created files I see that it actually does use nodejs8.10 which however conflicts Amplify's documentation. I don't see manually editing the files as a solution, as I don't want to inject my own code into what Amplify does automatically and might get overwritten at some point.

Anything I'm missing or doing wrong here?


Solution

  • Your Amplify CLI needs to be v4.10.0 or higher. Rerun the install to update:

    npm install -g @aws-amplify/cli
    

    Next time you run amplify in your codebase, it will suggest updating the node runtime version:

    $ 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
    

    Reference: 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.