Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to 10.8.1 returning failed to get profile credentials #12174

Closed
2 tasks done
adcanis opened this issue Mar 4, 2023 · 36 comments · Fixed by #12325
Closed
2 tasks done

upgrade to 10.8.1 returning failed to get profile credentials #12174

adcanis opened this issue Mar 4, 2023 · 36 comments · Fixed by #12325
Assignees
Labels
bug Something isn't working p1 pending-release Code has been merged but pending release platform Issues tied to the general CLI platform

Comments

@adcanis
Copy link

adcanis commented Mar 4, 2023

How did you install the Amplify CLI?

npm

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

19.6.0

Amplify CLI Version

10.8.2

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.

no

Describe the bug

upgrade to 10.8.2 fails to get profile credentials when performing amplify task. Sends Authorization request multiple times despite currently being logged in before failing with error:

"Failed to get profile credentials. Unexpected token A in JSON at position 0"

Expected behavior

should allow amplify commands the same as v10.8.0

Reproduction steps

  1. aws-vault exec
  2. authenticate
  3. update schema
  4. amplify push -y

Project Identifier

9004eca0-6404-4a91-9fae-e5a8474cb213

Log output

# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • 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.
@adcanis adcanis added the pending-triage Issue is pending triage label Mar 4, 2023
@adcanis
Copy link
Author

adcanis commented Mar 6, 2023

Seems to be an issue with pushing. I was able to pull, but it still kicked me to authorization 3 times

@josefaidt
Copy link
Contributor

Hey @adcanis 👋 thanks for raising this! Can you confirm your Amplify CLI version? The issue description mentions 10.8.2 though the latest is 10.8.1

@josefaidt josefaidt added platform Issues tied to the general CLI platform pending-response Issue is pending response from the issue author and removed pending-triage Issue is pending triage labels Mar 6, 2023
@adcanis
Copy link
Author

adcanis commented Mar 6, 2023

sorry yes your right. 10.8.1 and was working on 10.8.0

@josefaidt josefaidt added the pending-triage Issue is pending triage label Mar 6, 2023
@josefaidt josefaidt self-assigned this Mar 6, 2023
@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Mar 6, 2023
@josefaidt
Copy link
Contributor

Ah no worries just wanted to clarify 🙂 do you only experience this issue in this one project or are you able to execute commands outside the project?

@josefaidt josefaidt added the investigating This issue is being investigated label Mar 6, 2023
@adcanis adcanis changed the title upgrade to 10.8.2 returning failed to get profile credentials upgrade to 10.8.1 returning failed to get profile credentials Mar 6, 2023
@adcanis
Copy link
Author

adcanis commented Mar 6, 2023

This is the only project using SSO credentials.
EDIT I'll also add my config and credentials file:

Config

[profile <Profile name>]
sso_start_url = https://******.awsapps.com/start
sso_region = ca-central-1  
sso_account_id = **********
sso_role_name = *********
credential_process = aws sso login --profile <Profile name>
region = ca-central-1
output = json

Credentials

[<Profile name>]
aws_access_key_id=********************
aws_secret_access_key=***********************
aws_session_token=********************************

@josefaidt
Copy link
Contributor

Thanks for clarifying @adcanis , I'm going to take a further look at this one 🙂

@josefaidt
Copy link
Contributor

Hey @adcanis while we investigate this further can you run the same command with --debug to print the stack trace?

@adcanis
Copy link
Author

adcanis commented Mar 6, 2023

Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1

Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

BackendPullFault: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
    at syncCurrentCloudBackend (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/commands/push.js:59:15)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/commands/push.js:73:5)
    at async Object.executeAmplifyCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:181:9)
    at async executePluginModuleCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:144:5)
    at async executeCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:42:9)
    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:120:5)

Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
Error: connect EHOSTDOWN 169.254.169.254:80 - Local (192.168.1.141:50654)
    at internalConnect (net.js:934:16)
    at defaultTriggerAsyncIdScope (internal/async_hooks.js:452:18)
    at net.js:1022:9
    at processTicksAndRejections (internal/process/task_queues.js:77:11)

Session Identifier: b7bf36f2-a7eb-45fa-bda9-c18dc8f0eeb2

@josefaidt
Copy link
Contributor

Hey @adcanis thanks for pasting that output. I have not been able to reproduce this issue with just credentials on environment variables. Does aws-vault create a config or credentials file at ~/.aws/?

as a note, this may be fixed with #12139

@josefaidt josefaidt added the pending-response Issue is pending response from the issue author label Mar 6, 2023
@adcanis
Copy link
Author

adcanis commented Mar 6, 2023

@josefaidt aws-vault doesn't create a new config file or credentials file. Instead, it stores the temporary session credentials in memory. This has worked in multiple projects. I've also cleared aws-vault and used aws sso login --profile <profile name> and received the same multiple authentication pages throughout the push process before returning the same error

when I run aws sso login --profile <profile name> i get an additional error:

Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Mar 6, 2023
@josefaidt
Copy link
Contributor

Hey @adcanis can you paste the output of amplify/.config/local-aws-info.json?

@josefaidt josefaidt added the pending-response Issue is pending response from the issue author label Mar 6, 2023
@adcanis
Copy link
Author

adcanis commented Mar 6, 2023

{
  "dev": {
    "configLevel": "project",
    "useProfile": true,
    "profileName": "account-sso-dev"
  }
}

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Mar 6, 2023
@adcanis
Copy link
Author

adcanis commented Mar 6, 2023

@josefaidt if it helps. The issue seems to be related to my API. I've re-pulled the backend, making a small change to my Lambda and amplify push was successful. The API fails with error

Failed to get profile credentials. Unexpected token A in JSON at position 0

@josefaidt
Copy link
Contributor

Hey @adcanis thanks for posting that! Can you try running the command with the AWS_SDK_LOAD_CONFIG env var set to 1?

AWS_SDK_LOAD_CONFIG=1 amplify push -y

@josefaidt josefaidt added pending-response Issue is pending response from the issue author and removed investigating This issue is being investigated labels Mar 6, 2023
@adcanis
Copy link
Author

adcanis commented Mar 7, 2023

@josefaidt same thing

@josefaidt
Copy link
Contributor

Captured stack trace output for debugging

ProfileConfigurationError: Failed to get profile credentials
    at loadConfigurationForEnv (/snapshot/repo/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/configuration-manager.js:777:13)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Object.loadConfiguration (/snapshot/repo/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/configuration-manager.js:718:18)
    at async Object.configureWithCreds (/snapshot/repo/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/aws-utils/aws.js:34:18)
    at async Object.getConfiguredAWSClient (/snapshot/repo/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/index.js:281:3)
    at async getAWSClient (/snapshot/repo/build/node_modules/@aws-amplify/amplify-console-hosting/lib/utils/client-factory.js:18:10)
    at async Object.getAmplifyClient (/snapshot/repo/build/node_modules/@aws-amplify/amplify-console-hosting/lib/utils/client-factory.js:4:15)
    at async Object.generateTableContentForApp (/snapshot/repo/build/node_modules/@aws-amplify/amplify-console-hosting/lib/utils/table-utils.js:10:25)
    at async Object.status (/snapshot/repo/build/node_modules/@aws-amplify/amplify-console-hosting/lib/hosting/index.js:164:3)
    at async status (/snapshot/repo/build/node_modules/@aws-amplify/amplify-console-hosting/lib/index.js:29:5)
    at async showAmplifyConsoleHostingStatus (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/commands/status.js:62:13)
    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/commands/status.js:53:9)
    at async Object.executeAmplifyCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:189:9)
    at async executePluginModuleCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:135:5)
    at async executeCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:33:9)
    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:117:5)

Unexpected token A in JSON at position 0
ProcessCredentialsProviderFailure: Unexpected token A in JSON at position 0
    at /snapshot/repo/build/node_modules/aws-sdk/lib/credentials/process_credentials.js:142:13
    at ChildProcess.exithandler (child_process.js:374:7)
    at ChildProcess.emit (events.js:400:28)
    at ChildProcess.emit (domain.js:475:12)
    at maybeClose (internal/child_process.js:1088:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5)
⠧ Fetching AWS Amplify Console domains
Session Identifier: 3e45598e-b810-4408-9fd0-bf623bde9788

@adcanis
Copy link
Author

adcanis commented Mar 27, 2023

@josefaidt any luck on this?

@josefaidt
Copy link
Contributor

Hey @adcanis the team is actively investigating this issue for a fix

@pavellazar pavellazar mentioned this issue Mar 28, 2023
3 tasks
@pavellazar pavellazar linked a pull request Mar 28, 2023 that will close this issue
3 tasks
@adcanis
Copy link
Author

adcanis commented Mar 28, 2023

@josefaidt if it helps any, the issue only happens when the account exceeds the 8hr expiration. running aws sso login --profile <> then returns token expired. It is the same issue essentially as this: 7361

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@adcanis
Copy link
Author

adcanis commented Mar 29, 2023

I'm still seeing error "the provided token has expired"
Steps taken:

  • run aws sso logout
  • run aws sso login --profile <profile name>
  • run amplify push -y

@josefaidt josefaidt added the pending-release Code has been merged but pending release label Mar 29, 2023
@josefaidt josefaidt reopened this Mar 29, 2023
@josefaidt
Copy link
Contributor

Hey @adcanis this was closed from automation but has not quite been released. I've added pending-release and will circle back shortly!

@adcanis
Copy link
Author

adcanis commented Mar 29, 2023

@josefaidt thanks, I've added a new issue if you'd like to remove it #7789 it may outline the issue a little better

@adcanis
Copy link
Author

adcanis commented Apr 13, 2023

Just a follow up. The issue seems to be with aws sso. When aws sso login --profile <> is ran to login, it does not update the /.aws/credentials with the new AWS Access Key ID, AWS Secret Access Key, AWS Session Token. This throws the error experienced above.

What i've been doing now is logging in, then pasting the new credentials found in Command line or programmatic access and performing the amplify commands after.

@OperationalFallacy
Copy link

npx amplify --version
11.0.5

I've tried to use amplify first time and immediately ended up on this issue. Dear maintainers, this is the first thing customer sees when interacting with the library. I'm sorry to say this, but it's pretty terrible experience.

Every other web library I've used had flawless initial auth flow (usually oauth2 with GitHub).

@pavellazar
Copy link
Contributor

Hi @OperationalFallacy, sorry for late response. I am not able to reproduce the issue using latest Amplify CLI, can you provide more details about the issue you're having?

  1. which command is failing for you? can you provide the stack trace printed when you execute the command with --debug flag?
  2. can you provide a set of steps to reproduce the issue in a newly created project?
  3. can you share with us at [email protected] your ~/.aws/config file, please remove any sensitive information
  4. is your issue with selecting an AWS profile on amplify init or you're experiencing issues with the Social Sign-in Auth flow as described here: https://docs.amplify.aws/lib/auth/social/q/platform/js/

Thank you

@pavellazar
Copy link
Contributor

Closing, as we cannot reproduce any longer using latest CLI, if you're still experiencing the issue please create a new issue.

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@OperationalFallacy
Copy link

Hi @OperationalFallacy, sorry for late response. I am not able to reproduce the issue using latest Amplify CLI, can you provide more details about the issue you're having?

  1. which command is failing for you? can you provide the stack trace printed when you execute the command with --debug flag?
  2. can you provide a set of steps to reproduce the issue in a newly created project?
  3. can you share with us at [email protected] your ~/.aws/config file, please remove any sensitive information
  4. is your issue with selecting an AWS profile on amplify init or you're experiencing issues with the Social Sign-in Auth flow as described here: https://docs.amplify.aws/lib/auth/social/q/platform/js/

Thank you

Here's a full output on a freshly installed amplify package, new project.

amplify init
Note: It is recommended to run this command from the root of your app directory
? Enter a name for the project testapi
The following configuration will be applied:

Project information
| Name: testapi
| Environment: dev
| Default editor: Visual Studio Code
| App type: javascript
| Javascript framework: none
| Source Directory Path: src
| Distribution Directory Path: dist
| Build Command: npm run-script build
| Start Command: npm run-script start

? Initialize the project with the above configuration? No
? Enter a name for the environment dev
? Choose your default editor: Visual Studio Code
✔ Choose the type of app that you're building · javascript
Please tell us about your project
? What javascript framework are you using react
? Source Directory Path:  src
? Distribution Directory Path: build
? Build Command:  npm run-script build
? Start Command: npm run-script start
Using default provider  awscloudformation
? Select the authentication method you want to use: AWS profile

For more information on AWS Profiles, see:
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html

? Please choose the profile you want to use testprofile-sso-dev
🛑 Failed to get profile credentials
Cannot read properties of undefined (reading 'accessKeyId')

Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

Session Identifier: 83461e3a-9008-4ee5-92ae-8c376a5e103f

There is nothing special about profile, standard SSO

[profile testprofile-sso-dev]
sso_start_url = https://test.awsapps.com/start#/
sso_region = us-east-1
sso_account_id = xxx
sso_role_name = Developer
region = us-east-1
output = json

and its logged in and working properly, I've tried some simple operations like aws s3 ls

@thantos
Copy link

thantos commented Oct 9, 2023

Same issue as @OperationalFallacy. SSO profile is working for the SDK and CDK.

[profile my-profile]
sso_start_url = https://[redacted].awsapps.com/start
sso_region = us-east-1
sso_account_id = [redacted]
sso_role_name = [redacted]
region = us-east-1

@OperationalFallacy
Copy link

image

Amplify team, can you at least fix this error message?

Explain users what config it is, what credentials, and how to fix it.
Also you should explain why do they need to to use AWS_CONFIG_FILE or set AWS_SDK_LOAD_CONFIG=1

It's even more annoying to see this "helpful" message then the broken auth itself.

The auth workflow for local development remains an absolutely terrible experience on the platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p1 pending-release Code has been merged but pending release platform Issues tied to the general CLI platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants