Spaceship-prompt: AWS profile not showing using environment variables

Created on 3 Nov 2017  路  12Comments  路  Source: denysdovhan/spaceship-prompt

Not really know if this is an issue or the intended behaviour. I have several profiles configured in my .aws/profile file. To avoid do things in the wrong place I have not set a default profile, every time that I want to make something with AWS I set the proper profile using export AWS_PROFILE=AAA. I would love Spaceship theme shows the profile that have been set but it doesn't.

I'm using the default settings (property SPACESHIP_AWS_SHOW=true), iterm2 and, just in case, my profile file looks like:

[profile WWW]
output = json
region = eu-west-1

[profile AAA]
output = json
region = eu-west-2

[profile WWW1]
source_profile = WWW
region = eu-west-2

[profile WWW2]
source_profile = WWW
bug has-pr

Most helpful comment

@cdimitroulas @salmanulfarzy I (finally) created a PR for this. 馃槈

All 12 comments

I couldn't find a reference to AWS_PROFILE, I think it just hasn't been implemented yet.

FYI: here's the code for the AWS stuff:

https://github.com/denysdovhan/spaceship-zsh-theme/blob/cfbf4bac60461b61acb9fa92cbe578dd8f797c38/spaceship.zsh#L927

Umm, it's interesting, I have never seen AWS_DEFAULT_PROFILE variable before but the aws_cli (not SDK's) works if it's set. Maybe is some kind of legacy variable to preserve backward compatibility. Btw, it is nowhere in the amazon docs: http://docs.aws.amazon.com/cli/latest/userguide/cli-environment.html

Both could be added to the script logic but my opinion is to use only AWS_PROFILE since follows the Amazon specifications.

I don't use AWS, so you may be right that we should use AWS_PROFILE instead of AWS_DEFAULT_PROFILE. But could this break valid use cases?

It's a bit tricky. AWS_DEFAULT_PROFILE is only maintained for backward compatibility reasons and AWS encourage to use AWS_PROFILE.

The aws_cli uses the AWS_DEFAULT_PROFILE as default so, if it is set, AWS_PROFILE is ignored, BUT, all AWS SDK's (java, python, js...) ignore the AWS_DEFAULT_PROFILE variable so in the best case you will get an error and in the works one you will do stuff with the wrong profile if both variables are set...

Since both approaches have pros and cons I would just improve the README explaining the options and let the user to chose. It's really easy to change the behaviour.

Adding my two cents.

Id recommend having the default set to AWS_PROFILE even if you have this as a configurable option as most new toolsets (Terraform for example) - prefer the new recommended env variable.

I think this came with a newer version of the CLI. Before only the DEFAULT_PROFILE var was available. Which was implemented in PR https://github.com/denysdovhan/spaceship-zsh-theme/pull/165

At the moment it supports AWS_PROFILE env var to switch profiles. We can update the theme to support this.

_Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html_

@denysdovhan I will pick this up.

Any update on this @RolfKoenders ?

@salmanulfarzy Yes! I have played with it and have it working according to the new docs. Tomorrow i can push the branch (not able to at the moment sorry).

@RolfKoenders Any updates ?

Hey @RolfKoenders, sorry to ping you but it's been some time since any activity on this issue and just want to see where it's at. This change would be very beneficial so that the standard AWS_PROFILE env variable can be used.

If you have done this work already and are able to get your change pushed/merged that would be awesome!

@cdimitroulas @salmanulfarzy I (finally) created a PR for this. 馃槈

:+1:

its been merged! awesome tkx! [doh]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

martincartledge picture martincartledge  路  4Comments

janjur picture janjur  路  3Comments

AlecRust picture AlecRust  路  3Comments

Vvkmnn picture Vvkmnn  路  3Comments

oldchevy picture oldchevy  路  3Comments