amplify-cli: Cannot read property 'accessKeyId' of undefined, after latest update

Before opening, please confirm:

  • I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

17.7.1

Amplify CLI Version

8.1.0

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

N/A

Amplify Categories

auth, api

Amplify Commands

pull, push, status

Describe the bug

After running aws-vault exec foo When performing an amplify command, error Failed to get profile: Cannot read property 'accessKeyId' of undefined presents itself.

If I remove aws-vault, and create a credentials file in my ~/.aws folder and add the credentials there, I get a different error: Name: ResourceNotFoundException : Message: User pool **-******-******** does not exist.

Expected behavior

The command(s) should work

Reproduction steps

Using AWS-VAULT

  1. aws-vault exec foo All commands there after present error

GraphQL schema(s)

# Put schemas below this line


Log output

# Put your logs below this line


Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 53 (13 by maintainers)

Most upvoted comments

Hey @adcanis based on the error for “Cognito does not exist” it appears the Amplify CLI is successfully authenticating however is not able to find the resource in the specified account and region. If this is an existing project you have locally, is it possible the amplify/.config/local-aws-info.json file is pointing to a unintended profile for this environment?

{
  "dev": {
    "configLevel": "project",
    "useProfile": true,
    "profileName": "default"
  }
}

ok - I’m using an SSO profile to deploy. I run amplify init using a named profile appdeploy. No matter whether I call the --profile flag when I run amplify init and select appdeploy as the aws profile or not…it believes the access_key_id is “undefined”. However, when I change the name of that profile to default…all of a sudden it works.

There is clearly an bug for (at least) amplify init whereby under certain conditions, it won’t recognize any profile other than default.

Hey @vkanagarajan glad to hear you’re back up and running, and thanks @m98 for chiming in here! I’m glad to hear you’ve found value out of this thread!

Given the issue is now resolved I will close this for now, however if this issue reappears please reply back to this thread and we can re-open to investigate further 🙂

Hi guyz, I melt 3hours for this fucking problem:

$ amplify -v
11.0.5

$ amplify status # same for amplify publish

...

🛑 Failed to get profile credentials
Cannot read property 'accessKeyId' of undefined

And finally resolved it as below procedure with my profile set in ~/.aws/credentials:

$ amplify configure project
# > AWS Profile setting
# > Update AWS Profile
# > AWS profile
# > (Select your profile)

Hey @vkanagarajan I was able to reproduce this if I point my profileName in amplify/.config/local-aws-info.json to a profile name that does not exist on my machine:

{
  "dev": {
    "configLevel": "project",
    "useProfile": true,
    "profileName": "doesnotexist"
  }
}

Can you confirm the profile default exists within your AWS configuration at ~/.aws/credentials?

In the end, I had to completely get rid of my app’s backend in the AWS UI console, and start again from scratch with a brand new backend as I was losing far too much time over this. No idea what went wrong or how it got so badly out of sync.

Can confirm that deleting the amplify directory and then running amplify pull --appId ******** --envName *** to grab my backend files again fixed the issue for me with no weird side-effects. I didn’t need to delete my aws-exports.js.

@josefaidt @m98 Just wanted to say thanks for all the help. The resolution seems to be to remove the amplify directory and aws-exports.js file as @m98 mentioned. In my case I did not init, but rather pulled the existing project in.

I ran amplify init then enter the credentials (previously I created that credential by running amplify configure)