aws-amplify / amplify-cli

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Apache License 2.0
2.82k stars 820 forks source link

still throw "the runtime parameter of nodejs6.10 is no longer..." after updating all templates and functions to nodejs14.x #10780

Closed mybluedog24 closed 2 years ago

mybluedog24 commented 2 years ago

Before opening, please confirm:

JavaScript Framework

Angular

Amplify APIs

Authentication

Amplify Categories

auth

Environment information

``` # Put output below this line System: OS: Windows 10 10.0.19044 CPU: (8) x64 Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz Memory: 32.21 GB / 63.92 GB Binaries: Node: 14.17.6 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.11 - ~\AppData\Roaming\npm\yarn.CMD npm: 8.14.0 - ~\AppData\Roaming\npm\npm.CMD Browsers: Chrome: 103.0.5060.114 Edge: Spartan (44.19041.1266.0), Chromium (103.0.1264.62) Internet Explorer: 11.0.19041.1566 npmPackages: @angular-devkit/build-angular: ~0.901.5 => 0.901.5 @angular/animations: ^9.1.7 => 9.1.7 @angular/animations/browser: undefined () @angular/animations/browser/testing: undefined () @angular/cdk: ^9.2.3 => 9.2.3 @angular/cdk/a11y: undefined () @angular/cdk/accordion: undefined () @angular/cdk/bidi: undefined () @angular/cdk/clipboard: undefined () @angular/cdk/coercion: undefined () @angular/cdk/collections: undefined () @angular/cdk/drag-drop: undefined () @angular/cdk/keycodes: undefined () @angular/cdk/layout: undefined () @angular/cdk/observers: undefined () @angular/cdk/overlay: undefined () @angular/cdk/platform: undefined () @angular/cdk/portal: undefined () @angular/cdk/scrolling: undefined () @angular/cdk/stepper: undefined () @angular/cdk/table: undefined () @angular/cdk/testing: undefined () @angular/cdk/testing/protractor: undefined () @angular/cdk/testing/testbed: undefined () @angular/cdk/text-field: undefined () @angular/cdk/tree: undefined () @angular/cli: ~9.1.5 => 9.1.5 @angular/common: ~9.1.6 => 9.1.6 @angular/common/http: undefined () @angular/common/http/testing: undefined () @angular/common/testing: undefined () @angular/common/upgrade: undefined () @angular/compiler: ~9.1.6 => 9.1.6 @angular/compiler-cli: ~9.1.6 => 9.1.6 @angular/compiler/testing: undefined () @angular/core: ~9.1.6 => 9.1.6 @angular/core/testing: undefined () @angular/forms: ~9.1.6 => 9.1.6 @angular/language-service: ~9.1.6 => 9.1.6 @angular/material: ^9.2.3 => 9.2.3 @angular/material/autocomplete: undefined () @angular/material/autocomplete/testing: undefined () @angular/material/badge: undefined () @angular/material/badge/testing: undefined () @angular/material/bottom-sheet: undefined () @angular/material/bottom-sheet/testing: undefined () @angular/material/button: undefined () @angular/material/button-toggle: undefined () @angular/material/button-toggle/testing: undefined () @angular/material/button/testing: undefined () @angular/material/card: undefined () @angular/material/checkbox: undefined () @angular/material/checkbox/testing: undefined () @angular/material/chips: undefined () @angular/material/core: undefined () @angular/material/core/testing: undefined () @angular/material/datepicker: undefined () @angular/material/dialog: undefined () @angular/material/dialog/testing: undefined () @angular/material/divider: undefined () @angular/material/divider/testing: undefined () @angular/material/expansion: undefined () @angular/material/expansion/testing: undefined () @angular/material/form-field: undefined () @angular/material/form-field/testing: undefined () @angular/material/form-field/testing/control: undefined () @angular/material/grid-list: undefined () @angular/material/grid-list/testing: undefined () @angular/material/icon: undefined () @angular/material/icon/testing: undefined () @angular/material/input: undefined () @angular/material/input/testing: undefined () @angular/material/list: undefined () @angular/material/list/testing: undefined () @angular/material/menu: undefined () @angular/material/menu/testing: undefined () @angular/material/paginator: undefined () @angular/material/paginator/testing: undefined () @angular/material/progress-bar: undefined () @angular/material/progress-bar/testing: undefined () @angular/material/progress-spinner: undefined () @angular/material/progress-spinner/testing: undefined () @angular/material/radio: undefined () @angular/material/radio/testing: undefined () @angular/material/select: undefined () @angular/material/select/testing: undefined () @angular/material/sidenav: undefined () @angular/material/sidenav/testing: undefined () @angular/material/slide-toggle: undefined () @angular/material/slide-toggle/testing: undefined () @angular/material/slider: undefined () @angular/material/slider/testing: undefined () @angular/material/snack-bar: undefined () @angular/material/snack-bar/testing: undefined () @angular/material/sort: undefined () @angular/material/sort/testing: undefined () @angular/material/stepper: undefined () @angular/material/table: undefined () @angular/material/table/testing: undefined () @angular/material/tabs: undefined () @angular/material/tabs/testing: undefined () @angular/material/toolbar: undefined () @angular/material/tooltip: undefined () @angular/material/tree: undefined () @angular/platform-browser: ^9.1.7 => 9.1.7 @angular/platform-browser-dynamic: ~9.1.6 => 9.1.6 @angular/platform-browser-dynamic/testing: undefined () @angular/platform-browser/animations: undefined () @angular/platform-browser/testing: undefined () @angular/router: ~9.1.6 => 9.1.6 @angular/router/testing: undefined () @angular/router/upgrade: undefined () @angular/service-worker: ~9.1.6 => 9.1.11 @angular/service-worker/config: undefined () @asymmetrik/ngx-leaflet: ^7.0.0 => 7.0.0 @aws-amplify/ui-angular: ^0.2.6 => 0.2.6 @capacitor/android: ^2.1.0 => 2.1.0 @capacitor/cli: 2.1.0 => 2.1.0 @capacitor/core: 2.1.0 => 2.1.0 @capacitor/ios: ^2.5.0 => 2.5.0 @ionic-native/app-rate: ^5.26.0 => 5.26.0 @ionic-native/call-number: ^5.26.0 => 5.26.0 @ionic-native/core: ^5.0.7 => 5.25.0 @ionic-native/email-composer: ^5.26.0 => 5.26.0 @ionic-native/globalization: ^5.26.0 => 5.26.0 @ionic-native/google-analytics: ^5.26.0 => 5.26.0 @ionic-native/native-geocoder: ^5.26.0 => 5.26.0 @ionic-native/sms: ^5.26.0 => 5.26.0 @ionic-native/splash-screen: ^5.0.0 => 5.25.0 @ionic-native/status-bar: ^5.0.0 => 5.25.0 @ionic/angular: ^5.3.0 => 5.3.0 @ionic/angular-toolkit: ^2.1.1 => 2.2.0 @ionic/lab: 3.1.6 => 3.1.6 @juggle/resize-observer: ^3.3.1 => 3.3.1 @ngx-translate/core: ^12.1.2 => 12.1.2 @ngx-translate/http-loader: ^4.0.0 => 4.0.0 @types/jasmine: ~3.5.0 => 3.5.10 (3.4.5) @types/jasminewd2: ~2.0.3 => 2.0.8 @types/latlon-geohash: ^2.0.0 => 2.0.0 @types/leaflet: ^1.5.12 => 1.5.12 @types/node: ^12.12.47 => 12.12.47 @types/polylabel: ^1.0.5 => 1.0.5 aws-amplify: ^3.0.13 => 3.0.13 aws-amplify-angular: ^5.0.13 => 5.0.13 call-number: ^1.0.1 => 1.0.1 capacitor-app: 1.0.0 chart.js: ^2.9.3 => 2.9.4 codelyzer: ^5.1.2 => 5.2.2 cordova-plugin-apprate: ^1.5.0 => 1.5.0 cordova-plugin-dialogs: ^2.0.2 => 2.0.2 cordova-plugin-dialogs-tests: 2.0.2 cordova-plugin-email-composer: ^0.10.1 => 0.10.1 cordova-plugin-globalization: ^1.11.0 => 1.11.0 cordova-plugin-globalization-tests: 1.0.7-dev cordova-plugin-google-analytics: ^1.9.0 => 1.9.0 cordova-plugin-nativegeocoder: ^3.4.1 => 3.4.1 cordova-plugin-nativestorage: ^2.3.2 => 2.3.2 cordova-res: ^0.14.0 => 0.14.0 cordova-sms-plugin: ^1.0.2 => 1.0.2 cupertino-pane: ^1.2.7 => 1.2.7 echarts: ^5.2.1 => 5.2.1 example-typescript: 1.0.0 font-awesome: ^4.7.0 => 4.7.0 jasmine-core: ~3.5.0 => 3.5.0 (2.8.0) jasmine-spec-reporter: ~4.2.1 => 4.2.1 jetifier: ^1.6.6 => 1.6.6 karma: ~5.0.0 => 5.0.5 karma-chrome-launcher: ~3.1.0 => 3.1.0 karma-coverage-istanbul-reporter: ~2.1.0 => 2.1.1 karma-jasmine: ~3.0.1 => 3.0.3 karma-jasmine-html-reporter: ^1.4.2 => 1.5.3 latlon-geohash: ^2.0.0 => 2.0.0 leaflet: ^1.6.0 => 1.6.0 leaflet-easybutton: ^2.4.0 => 2.4.0 ngx-echarts: ^7.0.2 => 7.0.2 ngx-pinch-zoom: ^2.6.2 => 2.6.2 node-example: 1.0.0 polylabel: ^1.1.0 => 1.1.0 protractor: ~5.4.3 => 5.4.4 protractor-example: 1.0.0 rxjs: ~6.5.1 => 6.5.5 (6.5.4) rxjs/ajax: undefined () rxjs/fetch: undefined () rxjs/internal-compatibility: undefined () rxjs/operators: undefined () rxjs/testing: undefined () rxjs/webSocket: undefined () source-map-explorer: ^2.4.2 => 2.4.2 stream-browserify: ^3.0.0 => 3.0.0 (2.0.2) timers-browserify: ^2.0.11 => 2.0.11 ts-node: ~8.3.0 => 8.3.0 tslib: ^1.10.0 => 1.11.2 (1.11.1, 2.3.0, 2.3.1, 2.4.0) tslint: ~6.1.0 => 6.1.2 typescript: ~3.8.3 => 3.8.3 (3.6.5) typescript-example: 1.0.0 webpack-bundle-analyzer: ^3.8.0 => 3.8.0 zone.js: ~0.10.2 => 0.10.3 npmGlobalPackages: @angular/cli: 8.1.2 @aws-amplify/cli: 9.1.0 @ionic/cli: 6.9.1 azure-functions-core-tools: 3.0.3904 bower: 1.8.8 browserify: 17.0.0 cordova-res: 0.15.1 cordova: 9.0.0 github-labels: 0.8.0 gulp: 3.9.1 js-source-extractor: 1.1.7 lighthouse: 6.1.0 mapshaper: 0.5.14 mrgit: 1.0.0 ngx-unused-css: 2.1.0 npm-windows-upgrade: 6.0.1 npm: 8.14.0 npx: 10.2.0 serverless: 3.16.0 style-dictionary: 3.0.2 ts-node: 10.2.1 tslint-etc: 1.11.1 tslint: 6.1.2 tsup: 4.14.0 typescript: 3.9.5 yarn: 1.22.11 ```

Describe the bug

I was updating an old project which still contained nodejs6.10, nodejs8.10, nodejs10.x. I finally got it work and run amplify push successfully, but when checking on CloudFormation, it's still at status UPDATE_ROLLBACK_COMPLETE. By checking the stack it's UserPoolClientLambda in the auth stack throws error:

The following resource(s) failed to update: [UserPoolClientLambda]

Resource handler returned message: "The runtime parameter of nodejs6.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: 96d9449e-443c-48c7-8c66-e9b3226635a5)" (RequestToken: e6a35b7c-98b6-dbf5-ac48-
75ada0f316ff, HandlerErrorCode: InvalidRequest)

But all my template files and lambda functions are already nodejs14.x. I can't find anywhere that contains runtime nodejs6.10 in my files or functions.

Any help would be appreciated, thanks!

Expected behavior

Expected update stack successfully.

Reproduction steps

No this error when creating new project.

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

chrisbonifacio commented 2 years ago

Hi @mybluedog24 👋 thanks for raising this issue. It looks like this issue has more to do with the Amplify CLI than the JS library so I am transferring this over to the CLI repo for better support and feedback.

In the meantime, if you are able to reproduce this consistently on your end, can you please list some reproduction steps that led up to this error like how did you configure your auth resource, what other resources did you add if any, etc?

I would also suggest looking through similar issues, such as this one https://github.com/aws-amplify/amplify-cli/issues/3149, where other developers ran into a similar problem. Some possible solutions may include upgrading the Amplify CLI version to the latest and attempting to push again.

josefaidt commented 2 years ago

Hey @mybluedog24 :wave: to add on to @chrisbonifacio 's comment above, if you run amplify update auth does it prompt you to migrate the resource? If so, this should not only migrate your resource to use the latest structure, but also regenerate the CloudFormation template which should update this Lambda runtime version

mybluedog24 commented 2 years ago

Hey @mybluedog24 👋 to add on to @chrisbonifacio 's comment above, if you run amplify update auth does it prompt you to migrate the resource? If so, this should not only migrate your resource to use the latest structure, but also regenerate the CloudFormation template which should update this Lambda runtime version

Thank you for your response. I tried but it gives another error:

The following resource(s) failed to update: [UserPool].

Updates are not allowed for property - UsernameAttributes. (Service: AWSCognitoIdentityProvider; Status Code: 400; Error
 Code: InvalidParameterException; Request ID: null; Proxy: null)

I didn't update anything, just added a user pool group to trigger the update:

A migration is needed to support latest updates on auth resources.
Recommended to try in a non-production environment first. Run "amplify env add" to create or clone an environment.
Custom CloudFormation changes will NOT be preserved. Custom changes can be made with "amplify auth override" after migration.
Learn more about this migration: https://docs.amplify.aws/cli/migration/override
Do you want to migrate auth resource "xxxxxxxx"? (Y/n) · yes
Using service: Cognito, provided by: awscloudformation
 What do you want to do? Create or update Cognito user pool groups
? Provide a name for your user pool group: dummygroup
? Do you want to add another User Pool Group No
√ Sort the user pool groups in order of preference · dummygroup
mybluedog24 commented 2 years ago

I finally made it work. By checking my notes, Amplify cli can't set email as username before. So I manually added UsernameAttributes: - 'email' to the template yaml file when I first time created the project. And after adding this to new template files, it works:

// add below to "Parameters" in auth/xxxxxxx/build/xxxxxxx-cloudformation-template.json
    "usernameAttributes": {
      "Type": "CommaDelimitedList"
    },

// add below to auth/xxxxxxx/build/parameters.json
  "usernameAttributes": [
    "email"
  ],

// add below to cli-input.json
  "usernameAttributes": [
    "email"
  ],