Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amplify push results in The runtime parameter of nodejs12.x is no longer supported for creating or updating AWS Lambda functions #13949

Closed
2 tasks done
malcomm opened this issue Oct 1, 2024 · 12 comments
Labels
auth Issues tied to the auth category of the CLI functions Issues tied to the functions category pending-response Issue is pending response from the issue author pending-triage Issue is pending triage

Comments

@malcomm
Copy link

malcomm commented Oct 1, 2024

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

No response

Amplify CLI Version

12.12.6

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No

Describe the bug

amplify push results in a bunch of failures:

🛑 The following resources failed to deploy:
Resource Name: UserPoolClientLambda (AWS::Lambda::Function)
Event Type: create
Reason: Resource handler returned message: "The runtime parameter of nodejs12.x is no longer supported for creating or updating AWS Lambda functions. We recommend you use a supported runtime while creating or updating functions. (Service: Lambda, Status Code: 400, Request ID: 8e7a6def-5c99-4a5f-813b-b2bfe63d9513)" (RequestToken: 76bb2899-629c-aed5-d7e5-6086144a02c5, HandlerErrorCode: InvalidRequest)


Resource Name: PinpointFunction (AWS::Lambda::Function)
Event Type: create
Reason: Resource handler returned message: "The runtime parameter of nodejs12.x is no longer supported for creating or updating AWS Lambda functions. We recommend you use a supported runtime while creating or updating functions. (Service: Lambda, Status Code: 400, Request ID: 4dd57b21-99e4-4f48-8893-6975ca74cf93)" (RequestToken: 63501b23-0872-9a3d-7e43-ebe5278c1214, HandlerErrorCode: InvalidRequest)


🛑 Resource is not in the state stackUpdateComplete
Name: UserPoolClientLambda (AWS::Lambda::Function), Event Type: create, Reason: Resource handler returned message: "The runtime parameter of nodejs12.x is no longer supported for creating or updating AWS Lambda functions. We recommend you use a supported runtime while creating or updating functions. (Service: Lambda, Status Code: 400, Request ID: 8e7a6def-5c99-4a5f-813b-b2bfe63d9513)" (RequestToken: 76bb2899-629c-aed5-d7e5-6086144a02c5, HandlerErrorCode: InvalidRequest), IsCustomResource: false

Name: PinpointFunction (AWS::Lambda::Function), Event Type: create, Reason: Resource handler returned message: "The runtime parameter of nodejs12.x is no longer supported for creating or updating AWS Lambda functions. We recommend you use a supported runtime while creating or updating functions. (Service: Lambda, Status Code: 400, Request ID: 4dd57b21-99e4-4f48-8893-6975ca74cf93)" (RequestToken: 63501b23-0872-9a3d-7e43-ebe5278c1214, HandlerErrorCode: InvalidRequest), IsCustomResource: false

This happened when I was trying to make an update and I thought I had done something wrong. I ended up deleting the entire environment and tried to recreate ... same issue.

Expected behavior

push should work

Reproduction steps

amplify push ... failure

Project Identifier

No response

Log output

# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.
@malcomm malcomm added the pending-triage Issue is pending triage label Oct 1, 2024
@malcomm
Copy link
Author

malcomm commented Oct 2, 2024

Not sure if this matters or not but I'm using: GraphQL transformer version: 1

@ykethan
Copy link
Member

ykethan commented Oct 2, 2024

Hey @malcomm, thank you for reaching out. It appears the Lambda functions in the project currently use a deprecated runtime which will need to updated before pushing the environment. To update the function, you should be able to modify the runtime property on the function CloudFormation template function. Refer to the Amplify function document providing this information
did notice the UserPoolClientLambda also throw this error, you will need run amplify update auth to update the UserPoolClientLambda runtime, then run amplify build and the check the CloudFormation template to ensure the runtime has been updated. If you do not observe the updated runtime, on the update auth flow reselect your existing options which should regenerate the template.

@ykethan ykethan added functions Issues tied to the functions category auth Issues tied to the auth category of the CLI pending-response Issue is pending response from the issue author labels Oct 2, 2024
@malcomm
Copy link
Author

malcomm commented Oct 2, 2024

@ykethan - just to be sure ... these Lambda functions are being created by aws amplify cli ... my project doesn't have any custom Lambda functions. The PinpointFunction and UserPoolClientLambda are byproducts of adding the following amplify resources (via amplify add):

  • auth
  • analytics
  • api

So what I think is happening: the Lambda functions that aws amplify creates/maintains are not using the new node version.

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Oct 2, 2024
@ykethan
Copy link
Member

ykethan commented Oct 2, 2024

Hey @malcomm, thanks for pointing this. The UserPoolClientLambda on the auth resource should get updated to the latest runtime on running amplify update auth. Refer to this similar issue providing this information: #13726
The PinpointFunction will need to updated on the analytics CloudFormation template. Refer to the comments #13788 (comment) and #13788 (comment) providing this information.

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Oct 2, 2024
@malcomm
Copy link
Author

malcomm commented Oct 2, 2024

@ykethan - .......

So let me get this straight ... I have had a project going for many years and then yesterday I do a push. This results in the stack in a failed state with no way to recover it. I try everything I can think of to restore it ... no go. I then nuke the environment because I thought I was doing something wrong ... boy was that a mistake ... now I don't have a test environment to QA this auth change for my production environment.

You think it might be a good idea for the amplify cli team to maybe give a little warning about this whole thing? It's not like this is new ......

The hours this has just cost me ... and I don't even have this working again .....

Rant over ... I'll try and patch this up. Man do I ever regret picking AWS Amplify .....

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Oct 2, 2024
@malcomm
Copy link
Author

malcomm commented Oct 3, 2024

@ykethan - ok so I am trying to follow the steps #13788 (comment) and #13788 (comment) providing this information.

I installed installed Amplify CLI @ 11.1.0:

npm install -g @aws-amplify/[email protected]

Tried an amplify push and the push failed:

🛑 The following resources failed to deploy:
Resource Name: PinpointFunction (AWS::Lambda::Function)
Event Type: create
Reason: Resource handler returned message: "The runtime parameter of nodejs12.x is no longer supported for creating or updating AWS Lambda functions. We recommend you use a supported runtime while creating or updating functions. (Service: Lambda, Status Code: 400, Request ID: 8c2141cf-c873-4be3-8ac5-f67b71bc5c2e)" (RequestToken: 56ab9259-c9f5-40a4-0323-07850ebd4b25, HandlerErrorCode: InvalidRequest)


🛑 Resource is not in the state stackUpdateComplete
Name: PinpointFunction (AWS::Lambda::Function), Event Type: create, Reason: Resource handler returned message: "The runtime parameter of nodejs12.x is no longer supported for creating or updating AWS Lambda functions. We recommend you use a supported runtime while creating or updating functions. (Service: Lambda, Status Code: 400, Request ID: 8c2141cf-c873-4be3-8ac5-f67b71bc5c2e)" (RequestToken: 56ab9259-c9f5-40a4-0323-07850ebd4b25, HandlerErrorCode: InvalidRequest)

I am stuck with no way to deploy.

@malcomm
Copy link
Author

malcomm commented Oct 3, 2024

@ykethan - any chance we could get a new version of Amplify CLI that creates the PinpointFunction Lambda with the correct vesion?

@malcomm
Copy link
Author

malcomm commented Oct 7, 2024

@ykethan - any updates on this? Development is blocked 100% because of this issue.

@ykethan
Copy link
Member

ykethan commented Oct 9, 2024

Hey @malcomm, apologies for the delay in a response.
you will need to utilize the latest version of Amplify. following steps provide information on upgrading this function

  1. run amplify upgrade to upgrade the cli version. To verify if the cli was updated run amplify -v which should show the cli version greater than 12.
  2. open analytics CloudFormation template. amplify/backend/analytics/<name-of-resource>
  3. in the pinpoint-cloudformation-template.json, under PinpointFunction` block update this to
"PinpointFunction": {
      "Type": "AWS::Lambda::Function",
      "Condition": "ShouldCreatePinpointApp",
      "Properties": {
        "Code": {
          "ZipFile": {
            "Fn::Join": [
              "\n",
              [
                "const response = require('cfn-response');",
                "const { CloudFormationClient, DescribeStacksCommand } = require('@aws-sdk/client-cloudformation');",
                "const { PinpointClient, CreateAppCommand, DeleteAppCommand } = require('@aws-sdk/client-pinpoint');",
                "exports.handler = function(event, context) {",
                "    // Don't return promise, response.send() marks context as done internally",
                "    const ignoredPromise = handleEvent(event, context)",
                "};",
                "async function handleEvent(event, context) {",
                "    if (event.RequestType === 'Delete') {",
                "        try {",
                "            const stackID = event.StackId;",
                "            const cloudFormationClient = new CloudFormationClient({region: event.ResourceProperties.region});",
                "            const describeStacksOutput = await cloudFormationClient.send(new DescribeStacksCommand({StackName: stackID}));",
                "            let appId;",
                "            if (describeStacksOutput.Stacks && describeStacksOutput.Stacks.length > 0) {",
                "                const {Outputs} = describeStacksOutput.Stacks[0];",
                "                const appIdOutput = Outputs.find((output) => {",
                "                    return output.OutputKey === 'Id'",
                "                });",
                "                appId = appIdOutput ? appIdOutput.OutputValue : undefined;",
                "            }",
                "            if (appId) {",
                "                const pinpointClient = new PinpointClient({region: event.ResourceProperties.pingPointRegion});",
                "                const params = {",
                "                    ApplicationId: appId,",
                "                };",
                "                await pinpointClient.send(new DeleteAppCommand(params));",
                "            }",
                "            response.send(event, context, response.SUCCESS, {'message': `Successfully deleted pinpoint project`});",
                "        } catch (e) {",
                "            if (e.name !== 'NotFoundException') {",
                "                response.send(event, context, response.FAILED, {'message': `Failed to deleted Pinpoint project`, 'exception': e});",
                "            } else {",
                "                response.send(event, context, response.SUCCESS, {'message': `Successfully deleted pinpoint project`});",
                "            }",
                "        }",
                "    } else if (event.RequestType === 'Create') {",
                "        try {",
                "            const appName = event.ResourceProperties.appName;",
                "            const params = {",
                "                CreateApplicationRequest: {",
                "                    Name: appName",
                "                }",
                "            };",
                "            const pinpoint = new PinpointClient({region: event.ResourceProperties.pingPointRegion});",
                "            const res = await pinpoint.send(new CreateAppCommand(params));",
                "            response.send(event, context, response.SUCCESS, res.ApplicationResponse);",
                "        } catch (err) {",
                "            console.log(err.stack);",
                "            response.send(event, context, response.FAILED, {Error: err});",
                "        }",
                "    } else {",
                "        response.send(event, context, response.SUCCESS);",
                "    }",
                "};"
              ]
            ]
          }
        },
        "Handler": "index.handler",
        "Runtime": "nodejs18.x",
        "Timeout": 300,
        "Role": {
          "Fn::GetAtt": [
            "LambdaExecutionRole",
            "Arn"
          ]
        }
      }
    },
  1. run amplify status observe update status on analytics
  2. run amplify push

i would be happy in hopping on a call and assisting you as well. I am available on discord and my handle is ykethan

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Oct 9, 2024
@ykethan
Copy link
Member

ykethan commented Oct 9, 2024

@malcomm thank you for hopping on a call today, it was great chatting with you. Do let us know if the issue can be closed.

@ykethan
Copy link
Member

ykethan commented Oct 29, 2024

Closing the issue due to inactivity. Do reach out if you are still experiencing any issues.

@ykethan ykethan closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2024
Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issues tied to the auth category of the CLI functions Issues tied to the functions category pending-response Issue is pending response from the issue author pending-triage Issue is pending triage
Projects
None yet
Development

No branches or pull requests

2 participants