aws-amplify / amplify-cli

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

Amplify push error: Error updating cloudf✖ An error occurred when pushing the resources to the cloud #3869

Closed SeanDez closed 4 years ago

SeanDez commented 4 years ago

Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the Amplify Console GitHub Issue Tracker

Describe the bug

Full explanation provided here: https://stackoverflow.com/questions/61034318/aws-amplify-error-updating-cloudf-an-error-occurred-when-pushing-the-resources

To Reproduce

  1. Initialize amplify project with these settings:
$ amplify init
Note: It is recommended to run this command from the root of your app directory
? Choose your default editor: IDEA 14 CE
? Choose the type of app that you're buildi
ng javascript
Please tell us about your project
? What javascript framework are you using r
eact
? Source Directory Path:  src
? Distribution Directory Path: build
? Build Command:  npm run build
? Start Command: npm run-script start
Using default provider awscloudformation
  1. Add IAM user with AdministratorAccess role
  2. Run amplify add-auth and choose default config.
  3. Run amplify push and error should occur

Expected behavior

Successful, error free push.

Screenshots

Given in SO post above.

Desktop (please complete the following information):

kaustavghosh06 commented 4 years ago

You're exact error is:

CREATE_FAILED UserPoolClientLambda                                       AWS::Lambda::Function      Sun Apr 05 2020 02:33:43 GMT+0700 (Indochina Time) The runtime parameter of nodejs6.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: df1fc105-5078-471b-a6b9-6⠴ Updating resources in the cloud. This may take a few minutes...

You're using a CLI version 0.1.38 which is almost 2 years old. I would recommend installing the latest version of the CLI - using npm install -g @aws-amplify/cli command and try adding auth and pushing for new proojects.

SeanDez commented 4 years ago

@kaustavghosh06 , so far I have been unable to update the global package. amplify --version always returns 0.1.38. I have tried:

npm uninstall -g @aws-amplify/cli
npm install -g @aws-amplify/cli

npm update -g @aws-amplify/cli

npm uninstall -g aws-amplify
npm install -g aws-amplify

npm update -g aws-amplify

Any idea why this is not updating? Here is my package.json

{
  "name": "aws_amplify",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "@types/jest": "^24.0.0",
    "@types/node": "^12.0.0",
    "@types/react": "^16.9.0",
    "@types/react-dom": "^16.9.0",
    "antd": "^4.1.0",
    "aws-amplify-react": "^4.1.4",
    "jwt-decode": "^2.2.0",
    "password-validator": "^5.0.3",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.4.1",
    "styled-components": "^5.0.1",
    "typescript": "~3.7.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Here is my full terminal:


owner@G700:~/PhpstormProjects/aws_amplify$ amplify add hosting
? Select the environment setup: DEV (S3 only
 with HTTP)
? hosting bucket name amplify-test
? index doc for the website build/index.html

? error doc for the website index.html

You can now publish your app using the following command:
Command: amplify publish

owner@G700:~/PhpstormProjects/aws_amplify$ amplify publish
| Category | Resource name   | Operation | Provider plugin   |
| -------- | --------------- | --------- | ----------------- |
| Auth     | cognitob75feaf3 | Create    | awscloudformation |
| Hosting  | S3AndCloudFront | Create    | awscloudformation |
? Are you sure you want to continue? Yes
<removed>
CREATE_FAILED               authcognitob75feaf3       AWS::CloudFormation::Stack Mon Apr 06 2020 00:38:45 GMT+0700 (Indochina Time) Resource creation cancelled                                                               
UPDATE_ROLLBACK_COMPLETE awsamplify-20200405022907 AWS::CloudFormation::Stack Mon Apr 06 2020 00:40:05 GMT+0700 (Indochina Time) 
<removed>
DELETE_COMPLETE          authcognitob75feaf3       AWS::CloudFormation::Stack Mon Apr 06 2020 00:40:05 GMT+0700 (Indochina Time) 

✖ Error has occured during publish.
2020-04-05T17:40:15.498Z - error: uncaughtException: Cannot read property 'HostingBucketName' of undefined date=Mon Apr 06 2020 00:40:15 GMT+0700 (Indochina Time), pid=30877, uid=1000, gid=1000, cwd=/home/owner/PhpstormProjects/aws_amplify, execPath=/home/owner/.nvm/versions/node/v12.4.0/bin/node, version=v12.4.0, argv=[/home/owner/.nvm/versions/node/v12.4.0/bin/node, /usr/local/bin/amplify, publish], rss=103739392, heapTotal=58490880, heapUsed=54988680, external=3101842, loadavg=[1.796875, 1.94140625, 1.98291015625], uptime=629801, trace=[column=66, file=/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-hosting/lib/S3AndCloudFront/helpers/file-uploader.js, function=getHostingBucketName, line=37, method=null, native=false, column=29, file=/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-hosting/lib/S3AndCloudFront/helpers/file-uploader.js, function=Object.run, line=13, method=run, native=false, column=5, file=internal/process/task_queues.js, function=processTicksAndRejections, line=89, method=null, native=false], stack=[TypeError: Cannot read property 'HostingBucketName' of undefined,     at getHostingBucketName (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-hosting/lib/S3AndCloudFront/helpers/file-uploader.js:37:66),     at Object.run (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-hosting/lib/S3AndCloudFront/helpers/file-uploader.js:13:29),     at processTicksAndRejections (internal/process/task_queues.js:89:5)]
owner@G700:~/PhpstormProjects/aws_amplify$ aws --version
aws-cli/1.15.58 Python/3.5.2 Linux/4.15.0-88-generic botocore/1.10.57
owner@G700:~/PhpstormProjects/aws_amplify$ amplify --version
0.1.38
owner@G700:~/PhpstormProjects/aws_amplify$ npm i -g @aws-amplify/cli
<removed>
----------------------------------------
Successfully installed the Amplify CLI
----------------------------------------

npm WARN inquirer-autocomplete-prompt@1.0.2 requires a peer of inquirer@^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-compat@3.5.1 requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/@aws-amplify/cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ @aws-amplify/cli@4.17.2
updated 3 packages in 319.279s

owner@G700:~/PhpstormProjects/aws_amplify$ amplify --version
0.1.38
owner@G700:~/PhpstormProjects/aws_amplify$ npm update -g @aws-amplify/cli
owner@G700:~/PhpstormProjects/aws_amplify$ amplify --version
0.1.38

owner@G700:~/PhpstormProjects/aws_amplify$ npm uninstall -g @aws-amplify/cli
removed 1037 packages in 26.382s
owner@G700:~/PhpstormProjects/aws_amplify$ npm install -g @aws-amplify/cli

npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
/home/owner/.nvm/versions/node/v12.4.0/bin/amplify -> /home/owner/.nvm/versions/node/v12.4.0/lib/node_modules/@aws-amplify/cli/bin/amplify

> core-js@3.6.4 postinstall /home/owner/.nvm/versions/node/v12.4.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-graphql-types-generator/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

<removed>
----------------------------------------
Successfully installed the Amplify CLI
----------------------------------------
<removed>
+ @aws-amplify/cli@4.17.2
added 1035 packages from 711 contributors and updated 2 packages in 233.643s

owner@G700:~/PhpstormProjects/aws_amplify$ amplify --version
0.1.38
owner@G700:~/PhpstormProjects/aws_amplify$ npm update -g @aws-amplify/cli
owner@G700:~/PhpstormProjects/aws_amplify$ amplify --version
0.1.38
owner@G700:~/PhpstormProjects/aws_amplify$ npm i -g @amplify-cli@4.17.2

npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name "@amplify-cli": name can only contain URL-friendly characters

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/owner/.npm/_logs/2020-04-05T18_45_33_763Z-debug.log
owner@G700:~/PhpstormProjects/aws_amplify$ npm i -g @aws-amplify/cli@4.17.2
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
/home/owner/.nvm/versions/node/v12.4.0/bin/amplify -> /home/owner/.nvm/versions/node/v12.4.0/lib/node_modules/@aws-amplify/cli/bin/amplify

> @aws-amplify/cli@4.17.2 postinstall /home/owner/.nvm/versions/node/v12.4.0/lib/node_modules/@aws-amplify/cli
> node scripts/post-install.js

----------------------------------------
Successfully installed the Amplify CLI
----------------------------------------

JavaScript Getting Started - https://aws-amplify.github.io/docs/js/start

Android Getting Started - https://aws-amplify.github.io/docs/android/start

iOS Getting Started - https://aws-amplify.github.io/docs/ios/start

npm WARN inquirer-autocomplete-prompt@1.0.2 requires a peer of inquirer@^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-compat@3.5.1 requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/@aws-amplify/cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ @aws-amplify/cli@4.17.2
updated 1 package in 231.133s
owner@G700:~/PhpstormProjects/aws_amplify$ amplify --version
0.1.38
owner@G700:~/PhpstormProjects/aws_amplify$ npm update -g @aws-amplify
owner@G700:~/PhpstormProjects/aws_amplify$ npm i -g @aws-amplify
npm ERR! code EINVALIDTAGNAME
npm ERR! Invalid tag name "@aws-amplify": Tags may not have any characters that encodeURIComponent encodes.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/owner/.npm/_logs/2020-04-05T18_59_03_304Z-debug.log
owner@G700:~/PhpstormProjects/aws_amplify$ npm i -g aws-amplify

> fast-xml-parser@3.16.0 postinstall /home/owner/.nvm/versions/node/v12.4.0/lib/node_modules/aws-amplify/node_modules/fast-xml-parser
> node tasks/postinstall.js || exit 0

Love fast-xml-parser? Check https://amitkumargupta.work for more projects and contribution.

npm WARN @aws-amplify/core@3.2.1 requires a peer of @react-native-community/netinfo@^5.5.0 but none is installed. You must install peer dependencies yourself.
npm WARN @aws-amplify/api@3.1.4 requires a peer of @aws-amplify/pubsub@^2.1.1 but none is installed. You must install peer dependencies yourself.
npm WARN @aws-amplify/api-graphql@1.0.6 requires a peer of @aws-amplify/pubsub@^2.1.1 but none is installed. You must install peer dependencies yourself.

+ aws-amplify@3.0.5
added 146 packages from 412 contributors in 157.916s
owner@G700:~/PhpstormProjects/aws_amplify$ amplify --version
0.1.38
owner@G700:~/PhpstormProjects/aws_amplify$ npm update -g aws-amplify
owner@G700:~/PhpstormProjects/aws_amplify$ amplify -g --version
0.1.38
cyrfer commented 4 years ago

@SeanDez what does which amplify and which node show? Also, what is your node -v and npm -v ?

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.