amplify push results in The runtime parameter of nodejs12.x is no longer supported for creating or updating AWS Lambda functions
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:
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
Not sure if this matters or not but I'm using: GraphQL transformer version: 1
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 - 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.
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: https://github.com/aws-amplify/amplify-cli/issues/13726
The PinpointFunction will need to updated on the analytics CloudFormation template. Refer to the comments https://github.com/aws-amplify/amplify-cli/issues/13788#issuecomment-2126049333 and https://github.com/aws-amplify/amplify-cli/issues/13788#issuecomment-2127303131 providing this information.
@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 .....
@ykethan - ok so I am trying to follow the steps https://github.com/aws-amplify/amplify-cli/issues/13788#issuecomment-2126049333 and https://github.com/aws-amplify/amplify-cli/issues/13788#issuecomment-2127303131 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.
@ykethan - any chance we could get a new version of Amplify CLI that creates the PinpointFunction Lambda with the correct vesion?
@ykethan - any updates on this? Development is blocked 100% because of this issue.
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
- run
amplify upgradeto upgrade the cli version. To verify if the cli was updated runamplify -vwhich should show the cli version greater than 12. - open analytics CloudFormation template.
amplify/backend/analytics/<name-of-resource> - in the
pinpoint-cloudformation-template.json, underPinpointFunction` 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"
]
}
}
},
- run
amplify statusobserve update status on analytics - 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
@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.
Closing the issue due to inactivity. Do reach out if you are still experiencing any issues.
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.