aws-amplify / amplify-studio

AWS Amplify Studio (Formerly Admin UI)
136 stars 31 forks source link

amplify env add: Cannot read property 'idToken' of undefined #32

Closed blydewright closed 3 years ago

blydewright commented 3 years ago

Describe the bug I updated my CLI from 4.36.2 to 4.37.0 and ran amplify env add to create a new environment. It threw an error: amplify Cannot read property 'idToken' of undefined. When reverting back to 4.36.2, the same command worked.

Amplify CLI Version 4.37.0

To Reproduce Attempt to run amplify env add to a new environment name ("N" to would you like to use an existing env)

Expected behavior It shouldn't throw an error.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information): Mac OS Big Sur

Additional context Add any other context about the problem here.

jhockett commented 3 years ago

Hey @blydewright, I've been unable to reproduce so any additional information is appreciated.

  1. Can you show me the full output in the terminal?
  2. Have you enabled AdminUI in the console?
  3. Are you using an AWS profile?
blydewright commented 3 years ago

Hi @jhockett,

  1. I'll finish what I'm busy with and upgrade again to see if I can reproduce that output.
  2. Yes, as a matter of fact I enabled that for the first time today
  3. Yes
jhockett commented 3 years ago

@blydewright thanks for the information! I was able to reproduce and I marked the issue as a bug. The Amplify CLI is seeing that AdminUI is enabled and is expecting the new authentication method.

As a workaround until we can roll out a fix, you can use the new authentication method:

Then you should be able to create an environment like you normally would with amplify env add. Sorry to make you jump through hoops just to get unblocked. Please let me know if you have any questions about any of the steps above.

blydewright commented 3 years ago

Thanks for the workaround @jhockett :) You can also advise people to revert back to 4.36.2 - that seems to work as the admin UI feature is probably not recognised anyway. I'll keep my eye out for the fix. Also keen to see what this Admin UI is all about ;)

amlcodes commented 3 years ago

@jhockett no dice, A valid backend environment was not specified. in the ui, and I get the same Failed to fetch Amplify Admin credentials init failed Error: TypeError: Cannot read property 'idToken' of undefined at Object.getAwsConfig (/Users/amlcodes/.nvm/versions/node/v15.3.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/configuration-manager.js:761:13) error still when running amplify env add

blydewright commented 3 years ago

@amlcodes I have the same issue with my Admin UI interface in Console. Doesn't work, busy dealing with support on this. Have a feeling it isn't ready for use yet ;)

I reverted back to 4.36.2 so that CLI works for now.

morgler commented 3 years ago

Unfortunately @jhockett 's workaround didn't work for me (I always get a Failed to communnicate with the Amplify CLI. error in the Amplify Console). (BTW: that typo in the error message (commuNNicate) really is there and might need fixing as well)

But revering to 4.36.2 solved it.

blazinaj commented 3 years ago

Same issue here

antoniogiurini commented 3 years ago

Hello, could someone please explain how to revert to 4.36.2? I have 4.38.2, and I am having a similar problem while calling "amplify init".

Thanks

kaustavghosh06 commented 3 years ago

@antoniogiurini npm install -g @aws-amplify/cli@4.38.2

ywroh commented 3 years ago

@jhockett As you told me, I added the token, and amplify env add is now possible. Thank you.

Mac OS Big Sur Node Version v15.2.0 @aws-amplify/cli@4.38.2

antoniogiurini commented 3 years ago

Thanks @kaustavghosh06 My issue was solved by reverting to 4.36.2

Will try to finish the basic tutorial: https://aws.amazon.com/it/getting-started/hands-on/build-react-app-amplify-graphql/

FrankieJLyons commented 3 years ago

npm remove -g @aws-amplify/cli npm install -g @aws-amplify/cli@4.36.2

If you already ran amplify configure you don't need to again

amplify init --appId your-app-id

Worked for me

FrankieJLyons commented 3 years ago

oh I also went to ~/.aws/ and removed some useless profiles I made during my initial failed setup, in both the config and credentials file, and I set the [default] credentials to those that I set up with my amplify configure

blydewright commented 3 years ago

I believe the new CLI version 4.40.0 should address this issue but haven't tested yet :)

See changelog here: https://github.com/aws-amplify/amplify-cli/blob/master/packages/amplify-cli/CHANGELOG.md

ivmakk commented 3 years ago

I believe the new CLI version 4.40.0 should address this issue

Usage of 4.40.0 doesn't help for me. Same error happen when I'm trying to initialize a new project by amplify init Rolling back to 4.36.2 helps to solve the problem.

jhockett commented 3 years ago

I believe the new CLI version 4.40.0 should address this issue but haven't tested yet :)

See changelog here: https://github.com/aws-amplify/amplify-cli/blob/master/packages/amplify-cli/CHANGELOG.md

Sorry for any confusion, but the fix for this issue is still in progress.

watilde commented 3 years ago

I heard the same issue from a developer and am sharing what I found. In short, admin's config has a different appId with project's appId in some cases so that admin-helper's getRefreshedTokens returns undefined within amplify-provider-awscloudformation package. As work-around, the developer could add env by disabling adming ui that they doesn't use.

Stack trace:

  1. Takes appId from amplify/team-provider-info.json https://github.com/aws-amplify/amplify-cli/blob/master/packages/amplify-provider-awscloudformation/src/configuration-manager.ts#L717
  2. Takes config from ~/.amplify/admin/config.json and check with project's appId https://github.com/aws-amplify/amplify-cli/blob/master/packages/amplify-provider-awscloudformation/src/configuration-manager.ts#L718

A few options in my mind so far:

Townsheriff commented 3 years ago

I believe the new CLI version 4.40.0 should address this issue but haven't tested yet :) See changelog here: https://github.com/aws-amplify/amplify-cli/blob/master/packages/amplify-cli/CHANGELOG.md

Sorry for any confusion, but the fix for this issue is still in progress.

Not fixed in: 4.40.1

blydewright commented 3 years ago

I am running the latest CLI 4.40.1 without any issues. But I did disable the new Admin UI either before or after downgrading to 4.36.2, running a successful init or pull on that older version, before then upgrading back to the latest CLI.

michaelpaulcuccia commented 3 years ago

I've tried to set up this 'simple' react app 3x's already. This is incredibly complicated. Also, your GraphQL code in the later steps is mixed up...you have it as a TODO and as a NOTETAKER.

jacobdubail commented 3 years ago

by disabling the admin ui for all backend environments, I was able to get around this error. v:4.41.0

sithu951 commented 3 years ago

@jhockett, the workaround you mentioned worked for me to get temporary credentials and to start using amplify env add. But, in my original environment, I used existing cognito user pool with the command amplify import auth. When adding a new environment, the temporary credential created using the workaround you mentioned was not allowed to access the cognito user pool. It gave the following error:

AccessDeniedException: User: arn:aws:sts__assumed-role/ap-southeast-1__Full-access/amplifyadmin is not authorized to perform: cognito-idp:DescribeUserPool on resource: arn:aws:cognito-idp:ap-southeast-1:___:userpool/ap-southeast-1__

Is there a way to add cognito permissions to sts assumed-role?

As a workaround until we can roll out a fix, you can use the new authentication method:

cd to your project's root directory amplify console -> choose Amplify console from the side bar click on "Admin UI management" send yourself an invite and select "Full access" run amplify configure --appId --envName , login with the temporary credentials that were sent to the email address you picked above click "yes" in the browser when it asks to authenticate with the Amplify CLI Then you should be able to create an environment like you normally would with amplify env add. Sorry to make you jump through hoops just to get unblocked. Please let me know if you have any questions about any of the steps above.

jhockett commented 3 years ago

Hi @sithu951. That's a bug. I don't have a workaround for the moment, but I should have a fix for that in the Amplify CLI soon.

idobleicher commented 3 years ago

Hey, I have a kind of different issue, When I am trying to create a new env, it's written to me that Cognito pool is not existing '...CognitoId' When I disable the admin UI it's working.

I saw a Cognito pool in the Cognito. and it has users. (that the admin UI created) and the user I created.

But still seems not to work.

alissaVrk commented 3 years ago

btw, for me, disabling the admin UI solved the problem

mikelhamer commented 3 years ago

Experiencing this in 4.41.2

dcfranca commented 3 years ago

I have the same issue

When I click disable the Admin UI I get the following message:

Do you want to turn off the Admin UI? This will not delete your backend environment resources. This action canot be undone.

What does it mean as "the action cannot be undone", does it mean I can't enable it back when this issue is fixed? Is it safe to disable it?

igorimgn commented 3 years ago

I have the same issue

When I click disable the Admin UI I get the following message:

Do you want to turn off the Admin UI? This will not delete your backend environment resources. This action canot be undone.

What does it mean as "the action cannot be undone", does it mean I can't enable it back when this issue is fixed? Is it safe to disable it?

@dcfranca was it safe?

dcfranca commented 3 years ago

I have the same issue When I click disable the Admin UI I get the following message: Do you want to turn off the Admin UI? This will not delete your backend environment resources. This action canot be undone. What does it mean as "the action cannot be undone", does it mean I can't enable it back when this issue is fixed? Is it safe to disable it?

@dcfranca was it safe?

haven't continued lol

alissaVrk commented 3 years ago

@dcfranca @igorimgn I tried to set up admin UI again and at first I got " This app is not valid or was deleted."

BUT when I refreshed the amplify console and clicked the Open admin UI it worked (in my case, some things like content management never worked)

CharlieDigital commented 3 years ago

@mikelhamer

Experiencing this in 4.41.2

Same here (reporting for visibility).

Confirm that turning off the admin UI fixes the issue.

amypellegrini commented 3 years ago

I have this issue as well with version 4.41.2. I reverted back to version 4.36.2, but now I have this error:

File project: data should NOT have additional properties: 'frontend-ios'

jhockett commented 3 years ago

Hi all! We just released version 4.42.0 of the Amplify CLI. After upgrading, you should now be appropriately asked which authentication method you want to use even if the Admin UI is enabled.

idobleicher commented 3 years ago

Same issue still happend, while I am in 4.42.0 so it's not working! @jhockett image

jhockett commented 3 years ago

@iuyt9003 can you provide more context? What command did you use? Do you still see the error if you upgrade to the latest version of Amplify CLI?