Skip to content

Instantly share code, notes, and snippets.

@eramm
Last active September 27, 2023 15:45
Show Gist options
  • Save eramm/4c0b02d145662f8a78d11c1b44c615d8 to your computer and use it in GitHub Desktop.
Save eramm/4c0b02d145662f8a78d11c1b44c615d8 to your computer and use it in GitHub Desktop.
List your AWS Profiles

grep profile ~/.aws/config | sed -ne 's/^\[profile\s\(.*\)\]/export AWS_PROFILE=\1/p'

Note: If you are on a MacOS you will discover that this doesn't work due to the fun fact Mac does't use GNU sed ! (Boo Hiss !!!!) :-)

try this instead (2 ways): grep profile ~/.aws/config | sed -ne 's/^\[profile[[:space:]]\(.*\)\]/export AWS_PROFILE=\1/p'

grep profile ~/.aws/config | sed -ne 's/^\[profile\(.*\)\]/export AWS_PROFILE=\1/p' | sed 's/ //2'

@J00MZ
Copy link

J00MZ commented Jun 29, 2023

You can install gnu sed on MacOS using homebrew like so:
brew install gnu-sed
Then the first command works.
Although there is an extra " at the end there you might want to drop 😉

@eramm
Copy link
Author

eramm commented Sep 27, 2023

You can actually convert all your everything to GNU https://gist.github.com/skyzyx/3438280b18e4f7c490db8a2a2ca0b9da

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