aws-amplify / amplify-backend

Home to all tools related to Amplify's code-first DX (Gen 2) for building fullstack apps on AWS
Apache License 2.0
139 stars 46 forks source link

profiles with same name causes sandbox to fail with `The given region has not been bootstrapped` message #1573

Open ykethan opened 1 month ago

ykethan commented 1 month ago

Environment information

System:
  OS: macOS 14.5
  CPU: (8) arm64 Apple M1
  Memory: 168.66 MB / 16.00 GB
  Shell: /opt/homebrew/bin/fish
Binaries:
  Node: 20.11.1 - ~/.local/share/nvm/v20.11.1/bin/node
  Yarn: 1.22.19 - ~/.local/share/nvm/v20.11.1/bin/yarn
  npm: 10.2.4 - ~/.local/share/nvm/v20.11.1/bin/npm
  pnpm: 8.15.4 - ~/Library/pnpm/pnpm
NPM Packages:
  @aws-amplify/backend: 1.0.2
  @aws-amplify/backend-cli: 1.0.3
  aws-amplify: 6.3.2
  aws-cdk: 2.141.0
  aws-cdk-lib: 2.141.0
  typescript: 5.4.5
AWS environment variables:
  AWS_STS_REGIONAL_ENDPOINTS = regional
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
No CDK environment variable

Description

From comment: https://github.com/aws-amplify/amplify-backend/issues/1510#issuecomment-2115668240

if you have 2 profiles, 1 sso profile and 1 aws account profile with the same name. The sandbox picks the profile stored in ~/.aws/config instead of the SSO stored in ~/.aws/credentials

josefaidt commented 1 month ago

marking as a bug. The workaround would be to rename one of the profiles

edwardfoyle commented 1 month ago

Is the expected behavior here to fail with a better error message? Or to pick a different profile? Our code is not picking one over the other, we are using whatever is resolved by the default credential provider.

edwardfoyle commented 1 month ago

Based on https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-configured-credential-process.html and the env info above that shows AWS_SDK_LOAD_CONFIG = 1 was set, this looks like expected and documented behavior of the node credential provider. If AWS_SDK_LOAD_CONFIG is set, then the config file takes precedence over the credentials file.

redjonzaci commented 3 weeks ago

how do i help with this?