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

AWS_DEFAULT_PROFILE seems not supported by profile resolver #7676

Closed
dazza-codes opened this issue May 5, 2020 · 9 comments · Fixed by #8354
Closed

AWS_DEFAULT_PROFILE seems not supported by profile resolver #7676

dazza-codes opened this issue May 5, 2020 · 9 comments · Fixed by #8354

Comments

@dazza-codes
Copy link

There is no [default] in the ~/.aws/credentials or ~/.aws/config, to set and change profiles, the AWS_DEFAULT_PROFILE environment variable is used for awscli. But something in sls package is defaulting back to a default profile?

Serverless: Installing dependencies for custom CloudFormation resources...
 
  Serverless Error ---------------------------------------
 
  Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              10.20.1
     Framework Version:         1.68.0
     Plugin Version:            3.6.9
     SDK Version:               2.3.0
     Components Version:        2.30.4
 
@medikoo
Copy link
Contributor

medikoo commented May 6, 2020

@dazza-codes can you clarify in more details what's exactly your setup, and what you expect to happen?

Do you have e.g. foo profile configured in ~/.aws/credentials and ~/.aws/config, and AWS_DEFAULT_PROFILE set to foo, and you see it not resolved in a Framework?

@dazza-codes
Copy link
Author

Do you have e.g. foo profile configured in ~/.aws/credentials and ~/.aws/config, and AWS_DEFAULT_PROFILE set to foo, and you see it not resolved in a Framework?

Yes, exactly.

export AWS_DEFAULT_PROFILE=foo
##  ~/.aws/credentials
##  NO [default]
[foo]
... etc etc ..

@medikoo
Copy link
Contributor

medikoo commented May 28, 2020

@dazza-codes is AWS_DEFAULT_PROFILE env var supported naturally by AWS SDK?

@medikoo
Copy link
Contributor

medikoo commented Jul 20, 2020

Closing as we didn't receive enough details to process this further.

Also track #7605 as it might be related

@medikoo medikoo closed this as completed Jul 20, 2020
@dazza-codes
Copy link
Author

dazza-codes commented Jul 30, 2020

@medikoo - yes, the AWS_DEFAULT_PROFILE is sufficient for awscli to get everything required from ~/.aws/credentials

To work around the extra requirements to set a few more env-vars, I'm using a bash function to switch between profiles (there may be better options out there that I haven't found, but this seems to work OK when I have no default profile enabled and I have about 1/2 dozen different profiles in active use):

https://gist.github.com/dazza-codes/fe65f3214c7f2f189a928bee2524062e

@medikoo medikoo added bug and removed question labels Jul 31, 2020
@medikoo medikoo changed the title crash with default aws credentials, use AWS_DEFAULT_PROFILE AWS_DEFAULT_PROFILE seems not supported by profile resolver Jul 31, 2020
@medikoo
Copy link
Contributor

medikoo commented Jul 31, 2020

@dazza-codes thanks for further details. I believe problem lies in this line:

impl.addProfileCredentials(result, 'default');

As there we assume that default profile is default, where I believe we should respect AWS_DEFAULT_PROFILE.

PR with fix is welcome!

@marekpiotrowski
Copy link
Contributor

I'd like to take this one. Seems relatively easy, change in the implementation should be small, I will focus on tests, though. Let me know. Thank you.

@medikoo
Copy link
Contributor

medikoo commented Oct 7, 2020

@marekpiotrowski great to hear that! We look forward

@marekpiotrowski
Copy link
Contributor

Pull request created: #8354
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants