Added module to display current aws profile #26
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New Module
Added a module that displays the current value of the
AWS_PROFILE
environment variable which is used to distinguish which account to use when working with amazon web services command line tools.Why
I find that when I am working with tools to interact with Amazon Web Services via the command line I am constantly switching accounts as I have various work/personal accounts to manage. It can be annoying constantly checking which account I am currently interacting with, so I have added it to this great
PS1
.Background
AWS is a cloud platform with over 1 million customers [1] and is used by developers all over the world to run their code. Developers can interact with AWS via command line interface, sdks, and tools like terraform and packer.
When you want to interact with multiple AWS accounts via one machine you need to configure the command line by running configure commands, for example
aws configure --profile dev
andaws configure --profile prod
. Then you can specify which account you want to interact with in that shell session by runningexport AWS_PROFILE=dev
orexport AWS_PROFILE=prod
. This should help prevent deployingdev
resources in aprod
environment.I have not added support for the default profile that is selected when the
AWS_PROFILE
environment variable has not been set. Instead I have opted to hide the module. This is because I do not have a default account set as it is more likely to lead to running things in the incorrect account, I believe this is best practice. (If someone only has one account then using the default is fine, but I doubt they'd need theirPS1
to statically tell them they are on the default).See https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html for official information about how the profiles work.