Describe the bug
I can not add the Auth resource @1.1.2. I'm still getting There was an error adding the auth resource
To Reproduce
Steps to reproduce the behavior:
amplify auth add
amplify api add
/ amplify api update
with Amazon Cognito User Pool as authorization type for the APIExpected behavior
I was expecting the CLI to add an Auth resource to my backend.
Logs
Error: ENOENT: no such file or directory, open 'D:\projects\my-app\amplify\backend\auth\cognito94708cf9\parameters.json'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.writeFileSync (fs.js:1299:33)
at Object.saveResourceParameters (C:\Users\Nicolas\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\src\resourceParams.js:29:6)
at saveResourceParameters (C:\Users\Nicolas\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-category-auth\provider-utils\awscloudformation\index.js:59:12)
at serviceQuestions.then (C:\Users\Nicolas\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-category-auth\provider-utils\awscloudformation\index.js:96:7)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
There was an error adding the auth resource
Desktop (please complete the following information):
@NicolasRoehm Could you tell me what do you see when you do an amplify status
?
@kaustavghosh06 amplify status
gives the following :
Current Environment: dev
| Category | Resource name | Operation | Provider plugin |
| -------- | ------------- | --------- | --------------- |
@NicolasRoehm Looks like you havent added auth succesfully. Can you run amplify add auth
again and check amplify status? It should have an auth entry in it.
@kaustavghosh06 Here are the complete logs :
PS D:\projects\my-app> amplify add auth
Using service: Cognito, provided by: awscloudformation
The current configured provider is Amazon Cognito.
Do you want to use the default authentication and security configuration? Yes, use the default configuration.
Error: ENOENT: no such file or directory, open 'D:\projects\my-app\amplify\backend\auth\cognito627ca25a\parameters.json'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.writeFileSync (fs.js:1299:33)
at Object.saveResourceParameters (C:\Users\Nicolas\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\src\resourceParams.js:29:6)
at saveResourceParameters (C:\Users\Nicolas\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-category-auth\provider-utils\awscloudformation\index.js:59:12)
at serviceQuestions.then (C:\Users\Nicolas\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-category-auth\provider-utils\awscloudformation\index.js:96:7)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
There was an error adding the auth resource
PS D:\projects\my-app> amplify status
Current Environment: dev
| Category | Resource name | Operation | Provider plugin |
| -------- | ------------- | --------- | --------------- |
@NicolasRoehm could you try installing latest version of Amplify CLI. I tried adding auth in windows 10 and cmd and could not reproduce this error.
Hi @yuth, I get the exact same logs using @aws-amplify/[email protected]
Details
PS D:\projects\my-app> amplify auth add
Using service: Cognito, provided by: awscloudformation
The current configured provider is Amazon Cognito.
Do you want to use the default authentication and security configuration? Yes, use the default configuration.
Error: ENOENT: no such file or directory, open 'D:\projects\my-app\amplify\backend\auth\cognito915fc809\parameters.json'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.writeFileSync (fs.js:1299:33)
at Object.saveResourceParameters (C:\Users\Nicolas\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\src\resourceParams.js:29:6)
at saveResourceParameters (C:\Users\Nicolas\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-category-auth\provider-utils\awscloudformation\index.js:59:12)
at serviceQuestions.then (C:\Users\Nicolas\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-category-auth\provider-utils\awscloudformation\index.js:96:7)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
There was an error adding the auth resource
PS D:\projects\my-app> amplify status
Current Environment: dev
| Category | Resource name | Operation | Provider plugin |
| -------- | ------------- | --------- | --------------- |
@NicolasRoehm I couldn't reproduce this on Windows 10. Could you try running the same command with Windows Subsystem for Linux and see if this is still happens.
amplify status
shows Current Environment: undefined
after the same error returned by amplify auth add
:
nicolas@DESKTOP-42O95JU:~/code/my-app$ amplify auth add
Using service: Cognito, provided by: awscloudformation
The current configured provider is Amazon Cognito.
Do you want to use the default authentication and security configuration? Yes, use the default configuration.
Error: ENOENT: no such file or directory, open '/home/nicolas/code/my-app/amplify/backend/amplify-meta.json'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.readFileSync (fs.js:551:33)
at Object.updateamplifyMetaAfterResourceAdd (/usr/local/lib/node_modules/@aws-amplify/cli/src/extensions/amplify-helpers/update-amplify-meta.js:71:37)
at amplify.serviceSelectionPrompt.then.then (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-auth/commands/auth/enable.js:35:17)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
There was an error adding the auth resource
nicolas@DESKTOP-42O95JU:~/code/my-app$ amplify status
Current Environment: undefined
/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/gluegun/build/index.js:13
throw up;
^
Error: ENOENT: no such file or directory, open '/home/nicolas/code/my-app/amplify/backend/amplify-meta.json'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.readFileSync (fs.js:551:33)
at getResourceStatus (/usr/local/lib/node_modules/@aws-amplify/cli/src/extensions/amplify-helpers/resource-status.js:207:37)
at Object.showResourceTable (/usr/local/lib/node_modules/@aws-amplify/cli/src/extensions/amplify-helpers/resource-status.js:268:13)
at Command.run (/usr/local/lib/node_modules/@aws-amplify/cli/src/commands/status.js:5:27)
at Runtime.<anonymous> (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/gluegun/build/runtime/run.js:90:58)
at step (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/gluegun/build/runtime/run.js:32:23)
at Object.next (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/gluegun/build/runtime/run.js:13:53)
at /usr/local/lib/node_modules/@aws-amplify/cli/node_modules/gluegun/build/runtime/run.js:7:71
at new Promise (<anonymous>)
I had the same error.
The following steps worked for me:
amplify delete (in case you have an environment)
rm -rf aws-exports.js
amplify init
amplify auth add
amplify push
Hope it helps! 馃憤
Yes, it works! Thank you @lucaspelloni2 馃憤
Still hitting the same problem in Oct 2020 with amplify CLI version4.29.4
"@aws-amplify/ui-react": "^0.2.23",
"aws-amplify": "^3.3.3"
Unbelievable that Amplify is still riddled with all sorts of errors - even old ones like this bug.
Luckily, the workaround mentioned @lucaspelloni2 still works: thanks for that.
Most helpful comment
I had the same error.
The following steps worked for me:
Hope it helps! 馃憤