I recently wrote a script that switches your AWS default profile. After coming back to it a few weeks later I realized I could make it more elegant by relying directly on the ConfigParser library to modify the configuration instead of doing a line by line search and edit.
Here’s the improved version of the script itself which is still compatible with the command line function I mentioned in the earlier post:
The main reason I prefer this version is because there’s less risk of accidentally editing your credentials file with a mistakenly placed line. Instead I outsource the heavy lifting to the ConfigParser library and add in functionality to let you see what profiles you have available.
Let me know what you think!