NordicSemiconductor / asset-tracker-cloud-aws-js

A reference implementation of a serverless backend for an IoT product developed using AWS CDK in TypeScript.
https://github.com/NordicSemiconductor/asset-tracker-cloud-aws-js#readme
BSD 3-Clause "New" or "Revised" License
12 stars 4 forks source link

CDK deploy fails: nodejs8.10 is no longer supported #982

Closed ncmiller closed 2 years ago

ncmiller commented 2 years ago

Commit: v1.8.1

I'm trying to follow the Getting Started guide to run Asset Tracker V2 with AWS on a Thingy91, but I'm running into issues on the deployment step: https://nordicsemiconductor.github.io/asset-tracker-cloud-docs/v1.8.x/docs/aws/GettingStarted/Deploy.html.

The error I'm seeing:

The runtime parameter of nodejs8.10 is no longer supported for creating or updating AWS Lambda functions. We recommend you use the new runtime (nodejs16.x) while creating or updating functions. (Service: Lambda, Status Code: 400, Request ID: 0ff2cb86-2fb7-4409-97a9-3b8c8b10a866)" (RequestToken: 604776d7-9522-c225-83ce-5eb836dbe435, HandlerErrorCode: InvalidRequest)

Any recommendations to help get past this? Thanks in advance.

Here's the full output:

nick@nick-ThinkPad-P15s-Gen-2i:~/src/nrf-asset-tracker/aws$ npx cdk deploy '*'
base-layer-0de4305680d89797459863087216f3676802f515 ✔️
createThingGroup ✔️
bifravst: deploying...
bifravst: creating CloudFormation changeset...
  0/18 | 12:04:34 PM | CREATE_IN_PROGRESS   | AWS::IAM::Role                           | iotJitpRole (iotJitpRole7B509A5D)
  0/18 | 12:04:34 PM | CREATE_IN_PROGRESS   | AWS::Lambda::LayerVersion                | bifravst-layer (bifravstlayer761A9A78)
  0/18 | 12:04:35 PM | CREATE_IN_PROGRESS   | AWS::CDK::Metadata                       | CDKMetadata
  0/18 | 12:04:35 PM | CREATE_IN_PROGRESS   | AWS::IoT::Policy                         | thingPolicy
  0/18 | 12:04:35 PM | CREATE_IN_PROGRESS   | AWS::Cognito::UserPool                   | userPool (userPoolDC9497E0)
  0/18 | 12:04:35 PM | CREATE_IN_PROGRESS   | AWS::IAM::Role                           | iotJitpRole (iotJitpRole7B509A5D) Resource creation Initiated
  0/18 | 12:04:35 PM | CREATE_IN_PROGRESS   | AWS::S3::Bucket                          | websitBucket (websitBucketC74C6FBF)
  0/18 | 12:04:35 PM | CREATE_IN_PROGRESS   | AWS::IAM::Role                           | bifravst-ThingGroupLambda/ServiceRole (bifravstThingGroupLambdaServiceRole5C140D06)
  0/18 | 12:04:35 PM | CREATE_IN_PROGRESS   | AWS::S3::Bucket                          | websitBucket (websitBucketC74C6FBF) Resource creation Initiated
  0/18 | 12:04:36 PM | CREATE_IN_PROGRESS   | AWS::IAM::Role                           | bifravst-ThingGroupLambda/ServiceRole (bifravstThingGroupLambdaServiceRole5C140D06) Resource creation Initiated
  0/18 | 12:04:36 PM | CREATE_IN_PROGRESS   | AWS::CDK::Metadata                       | CDKMetadata Resource creation Initiated
  0/18 | 12:04:36 PM | CREATE_IN_PROGRESS   | AWS::IoT::Policy                         | thingPolicy Resource creation Initiated
  1/18 | 12:04:37 PM | CREATE_COMPLETE      | AWS::CDK::Metadata                       | CDKMetadata
  2/18 | 12:04:37 PM | CREATE_COMPLETE      | AWS::IoT::Policy                         | thingPolicy
  2/18 | 12:04:37 PM | CREATE_IN_PROGRESS   | AWS::Cognito::UserPool                   | userPool (userPoolDC9497E0) Resource creation Initiated
  3/18 | 12:04:38 PM | CREATE_COMPLETE      | AWS::Cognito::UserPool                   | userPool (userPoolDC9497E0)
  3/18 | 12:04:40 PM | CREATE_IN_PROGRESS   | AWS::Lambda::LayerVersion                | bifravst-layer (bifravstlayer761A9A78) Resource creation Initiated
  3/18 | 12:04:40 PM | CREATE_IN_PROGRESS   | AWS::Cognito::UserPoolClient             | userPoolClient (userPoolClientB67490F4)
  4/18 | 12:04:40 PM | CREATE_COMPLETE      | AWS::Lambda::LayerVersion                | bifravst-layer (bifravstlayer761A9A78)
  4/18 | 12:04:42 PM | CREATE_IN_PROGRESS   | AWS::Cognito::UserPoolClient             | userPoolClient (userPoolClientB67490F4) Resource creation Initiated
  5/18 | 12:04:42 PM | CREATE_COMPLETE      | AWS::Cognito::UserPoolClient             | userPoolClient (userPoolClientB67490F4)
  5/18 | 12:04:45 PM | CREATE_IN_PROGRESS   | AWS::Cognito::IdentityPool               | identityPool
  5/18 | 12:04:47 PM | CREATE_IN_PROGRESS   | AWS::Cognito::IdentityPool               | identityPool Resource creation Initiated
  6/18 | 12:04:47 PM | CREATE_COMPLETE      | AWS::Cognito::IdentityPool               | identityPool
  6/18 | 12:04:49 PM | CREATE_IN_PROGRESS   | AWS::IAM::Role                           | userRole (userRole628CAF3C)
  6/18 | 12:04:50 PM | CREATE_IN_PROGRESS   | AWS::IAM::Role                           | unauthenticatedUserRole (unauthenticatedUserRole4E9F10FA)
  6/18 | 12:04:50 PM | CREATE_IN_PROGRESS   | AWS::IAM::Role                           | userRole (userRole628CAF3C) Resource creation Initiated
  6/18 | 12:04:50 PM | CREATE_IN_PROGRESS   | AWS::IAM::Role                           | unauthenticatedUserRole (unauthenticatedUserRole4E9F10FA) Resource creation Initiated
  7/18 | 12:04:54 PM | CREATE_COMPLETE      | AWS::IAM::Role                           | iotJitpRole (iotJitpRole7B509A5D)
  8/18 | 12:04:55 PM | CREATE_COMPLETE      | AWS::IAM::Role                           | bifravst-ThingGroupLambda/ServiceRole (bifravstThingGroupLambdaServiceRole5C140D06)
  9/18 | 12:04:57 PM | CREATE_COMPLETE      | AWS::S3::Bucket                          | websitBucket (websitBucketC74C6FBF)
  9/18 | 12:04:57 PM | CREATE_IN_PROGRESS   | AWS::IAM::Policy                         | bifravst-ThingGroupLambda/ServiceRole/DefaultPolicy (bifravstThingGroupLambdaServiceRoleDefaultPolicy7F1A7E6B)
  9/18 | 12:04:58 PM | CREATE_IN_PROGRESS   | AWS::IAM::Policy                         | bifravst-ThingGroupLambda/ServiceRole/DefaultPolicy (bifravstThingGroupLambdaServiceRoleDefaultPolicy7F1A7E6B) Resource creation Initiated
  9/18 | 12:04:59 PM | CREATE_IN_PROGRESS   | AWS::S3::BucketPolicy                    | websitBucket/Policy (websitBucketPolicy32919A65)
  9/18 | 12:04:59 PM | CREATE_IN_PROGRESS   | AWS::CloudFront::Distribution            | websiteDistribution
  9/18 | 12:05:00 PM | CREATE_IN_PROGRESS   | AWS::S3::BucketPolicy                    | websitBucket/Policy (websitBucketPolicy32919A65) Resource creation Initiated
 10/18 | 12:05:01 PM | CREATE_COMPLETE      | AWS::S3::BucketPolicy                    | websitBucket/Policy (websitBucketPolicy32919A65)
 10/18 | 12:05:02 PM | CREATE_IN_PROGRESS   | AWS::CloudFront::Distribution            | websiteDistribution Resource creation Initiated
 11/18 | 12:05:09 PM | CREATE_COMPLETE      | AWS::IAM::Role                           | userRole (userRole628CAF3C)
 12/18 | 12:05:09 PM | CREATE_COMPLETE      | AWS::IAM::Role                           | unauthenticatedUserRole (unauthenticatedUserRole4E9F10FA)
 12/18 | 12:05:12 PM | CREATE_IN_PROGRESS   | AWS::Cognito::IdentityPoolRoleAttachment | identityPoolRoles
 12/18 | 12:05:14 PM | CREATE_IN_PROGRESS   | AWS::Cognito::IdentityPoolRoleAttachment | identityPoolRoles Resource creation Initiated
 13/18 | 12:05:14 PM | CREATE_COMPLETE      | AWS::Cognito::IdentityPoolRoleAttachment | identityPoolRoles
 14/18 | 12:05:17 PM | CREATE_COMPLETE      | AWS::IAM::Policy                         | bifravst-ThingGroupLambda/ServiceRole/DefaultPolicy (bifravstThingGroupLambdaServiceRoleDefaultPolicy7F1A7E6B)
 14/18 | 12:05:19 PM | CREATE_IN_PROGRESS   | AWS::Lambda::Function                    | bifravst-ThingGroupLambda (bifravstThingGroupLambda198905BE)
 14/18 | 12:05:21 PM | CREATE_IN_PROGRESS   | AWS::Lambda::Function                    | bifravst-ThingGroupLambda (bifravstThingGroupLambda198905BE) Resource creation Initiated
 15/18 | 12:05:22 PM | CREATE_FAILED        | AWS::Lambda::Function                    | bifravst-ThingGroupLambda (bifravstThingGroupLambda198905BE) Resource handler returned message: "The runtime parameter of nodejs8.10 is no longer supported for creating or updating AWS Lambda functions. We recommend you use the new runtime (nodejs16.x) while creating or updating functions. (Service: Lambda, Status Code: 400, Request ID: 0ff2cb86-2fb7-4409-97a9-3b8c8b10a866)" (RequestToken: 604776d7-9522-c225-83ce-5eb836dbe435, HandlerErrorCode: InvalidRequest)
        new Function (/home/nick/src/nrf-asset-tracker/aws/node_modules/@aws-cdk/aws-lambda/lib/function.js:72:26)
        \_ new BifravstStack (/home/nick/src/nrf-asset-tracker/aws/dist/cdk/stacks/Bifravst.js:205:74)
        \_ new BifravstApp (/home/nick/src/nrf-asset-tracker/aws/dist/cdk/apps/Bifravst.js:8:9)
        \_ main (/home/nick/src/nrf-asset-tracker/aws/dist/cdk/cloudformation.js:46:5)
        \_ processTicksAndRejections (node:internal/process/task_queues:96:5)
 16/18 | 12:05:22 PM | CREATE_FAILED        | AWS::CloudFront::Distribution            | websiteDistribution Resource creation cancelled
        new BifravstStack (/home/nick/src/nrf-asset-tracker/aws/dist/cdk/stacks/Bifravst.js:105:30)
        \_ new BifravstApp (/home/nick/src/nrf-asset-tracker/aws/dist/cdk/apps/Bifravst.js:8:9)
        \_ main (/home/nick/src/nrf-asset-tracker/aws/dist/cdk/cloudformation.js:46:5)
        \_ processTicksAndRejections (node:internal/process/task_queues:96:5)
 16/18 | 12:05:23 PM | ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack               | bifravst The following resource(s) failed to create: [bifravstThingGroupLambda198905BE, websiteDistribution]. Rollback requested by user.
 16/18 | 12:05:33 PM | DELETE_IN_PROGRESS   | AWS::CDK::Metadata                       | CDKMetadata
 16/18 | 12:05:33 PM | DELETE_IN_PROGRESS   | AWS::IoT::Policy                         | thingPolicy
 16/18 | 12:05:33 PM | DELETE_IN_PROGRESS   | AWS::S3::BucketPolicy                    | websitBucket/Policy (websitBucketPolicy32919A65)
 16/18 | 12:05:33 PM | DELETE_IN_PROGRESS   | AWS::CloudFront::Distribution            | websiteDistribution
 16/18 | 12:05:33 PM | DELETE_IN_PROGRESS   | AWS::IAM::Role                           | iotJitpRole (iotJitpRole7B509A5D)
 16/18 | 12:05:33 PM | DELETE_IN_PROGRESS   | AWS::Cognito::IdentityPoolRoleAttachment | identityPoolRoles
 16/18 | 12:05:33 PM | DELETE_IN_PROGRESS   | AWS::Lambda::Function                    | bifravst-ThingGroupLambda (bifravstThingGroupLambda198905BE)
 17/18 | 12:05:34 PM | DELETE_COMPLETE      | AWS::S3::BucketPolicy                    | websitBucket/Policy (websitBucketPolicy32919A65)
 18/18 | 12:05:34 PM | DELETE_COMPLETE      | AWS::IAM::Role                           | iotJitpRole (iotJitpRole7B509A5D)
 19/18 | 12:05:34 PM | DELETE_COMPLETE      | AWS::CDK::Metadata                       | CDKMetadata
 20/18 | 12:05:35 PM | DELETE_COMPLETE      | AWS::Cognito::IdentityPoolRoleAttachment | identityPoolRoles
 21/18 | 12:05:35 PM | DELETE_COMPLETE      | AWS::IoT::Policy                         | thingPolicy
 21/18 | 12:05:36 PM | DELETE_IN_PROGRESS   | AWS::IAM::Role                           | unauthenticatedUserRole (unauthenticatedUserRole4E9F10FA)
 21/18 | 12:05:36 PM | DELETE_IN_PROGRESS   | AWS::IAM::Role                           | userRole (userRole628CAF3C)
 22/18 | 12:05:37 PM | DELETE_COMPLETE      | AWS::IAM::Role                           | unauthenticatedUserRole (unauthenticatedUserRole4E9F10FA)
 23/18 | 12:05:38 PM | DELETE_COMPLETE      | AWS::IAM::Role                           | userRole (userRole628CAF3C)
 23/18 | 12:05:39 PM | DELETE_IN_PROGRESS   | AWS::Cognito::IdentityPool               | identityPool
 24/18 | 12:05:40 PM | DELETE_COMPLETE      | AWS::Lambda::Function                    | bifravst-ThingGroupLambda (bifravstThingGroupLambda198905BE)
 25/18 | 12:05:40 PM | DELETE_COMPLETE      | AWS::Cognito::IdentityPool               | identityPool
 25/18 | 12:05:41 PM | DELETE_IN_PROGRESS   | AWS::IAM::Policy                         | bifravst-ThingGroupLambda/ServiceRole/DefaultPolicy (bifravstThingGroupLambdaServiceRoleDefaultPolicy7F1A7E6B)
 25/18 | 12:05:41 PM | DELETE_IN_PROGRESS   | AWS::Lambda::LayerVersion                | bifravst-layer (bifravstlayer761A9A78)
 25/18 | 12:05:41 PM | DELETE_IN_PROGRESS   | AWS::Cognito::UserPoolClient             | userPoolClient (userPoolClientB67490F4)
 26/18 | 12:05:42 PM | DELETE_COMPLETE      | AWS::IAM::Policy                         | bifravst-ThingGroupLambda/ServiceRole/DefaultPolicy (bifravstThingGroupLambdaServiceRoleDefaultPolicy7F1A7E6B)
 27/18 | 12:05:42 PM | DELETE_COMPLETE      | AWS::Cognito::UserPoolClient             | userPoolClient (userPoolClientB67490F4)
 28/18 | 12:05:42 PM | DELETE_COMPLETE      | AWS::Lambda::LayerVersion                | bifravst-layer (bifravstlayer761A9A78)
 28/18 | 12:05:43 PM | DELETE_IN_PROGRESS   | AWS::IAM::Role                           | bifravst-ThingGroupLambda/ServiceRole (bifravstThingGroupLambdaServiceRole5C140D06)
 28/18 | 12:05:43 PM | DELETE_IN_PROGRESS   | AWS::Cognito::UserPool                   | userPool (userPoolDC9497E0)
 29/18 | 12:05:44 PM | DELETE_COMPLETE      | AWS::IAM::Role                           | bifravst-ThingGroupLambda/ServiceRole (bifravstThingGroupLambdaServiceRole5C140D06)
 30/18 | 12:05:45 PM | DELETE_COMPLETE      | AWS::Cognito::UserPool                   | userPool (userPoolDC9497E0)
30/18 Currently in progress: bifravst, websiteDistribution
 31/18 | 12:08:42 PM | DELETE_COMPLETE      | AWS::CloudFront::Distribution            | websiteDistribution
 31/18 | 12:08:43 PM | DELETE_IN_PROGRESS   | AWS::S3::Bucket                          | websitBucket (websitBucketC74C6FBF)
 32/18 | 12:08:44 PM | DELETE_COMPLETE      | AWS::S3::Bucket                          | websitBucket (websitBucketC74C6FBF)

 ❌  bifravst failed: Error: The stack named bifravst failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE
    at /home/nick/src/nrf-asset-tracker/aws/node_modules/cdk/node_modules/aws-cdk/lib/api/util/cloudformation.ts:163:13
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at waitFor (/home/nick/src/nrf-asset-tracker/aws/node_modules/cdk/node_modules/aws-cdk/lib/api/util/cloudformation.ts:76:20)
    at Object.deployStack (/home/nick/src/nrf-asset-tracker/aws/node_modules/cdk/node_modules/aws-cdk/lib/api/deploy-stack.ts:98:3)
    at CdkToolkit.deploy (/home/nick/src/nrf-asset-tracker/aws/node_modules/cdk/node_modules/aws-cdk/lib/cdk-toolkit.ts:120:24)
    at main (/home/nick/src/nrf-asset-tracker/aws/node_modules/cdk/node_modules/aws-cdk/bin/cdk.ts:192:16)
    at initCommandLine (/home/nick/src/nrf-asset-tracker/aws/node_modules/cdk/node_modules/aws-cdk/bin/cdk.ts:150:9)
The stack named bifravst failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE
ncmiller commented 2 years ago

I was able to get past this error by using the docs and code from the saga branch: https://nordicsemiconductor.github.io/asset-tracker-cloud-docs/saga/docs/aws/GettingStarted/Deploy.html.

The main Nordic page links to branch 1.8.x, so perhaps that page should be updated to point to saga: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/asset_tracker_v2/doc/asset_tracker_v2_description.html

Feel free to close this issue.

coderbyheart commented 2 years ago

Good catch! This should be fixable by bumping the Lambda Node.js version to nodejs16.x.

Will have a look this week.

coderbyheart commented 2 years ago

Are you sure that you were checking out the v1.8.x branch? Because the ThingGroupLambda is using Node.js 14.

coderbyheart commented 2 years ago

I've ran the tests in the v1.8.x branch and they pass, the deployment works without a problem.