Last active
March 28, 2020 17:01
-
-
Save neerajjose/b4ed6ff41ebc746ef1e80df5e974453d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env python | |
| # Author: Neeraj | |
| # Email: neerajjose@gmail.com | |
| import configparser | |
| from consolemenu import SelectionMenu | |
| def load_config(file): | |
| config = configparser.ConfigParser() | |
| config.read(file) | |
| return(config,config.sections()) | |
| def show_menu(menu): | |
| try: | |
| return(menu[SelectionMenu.get_selection(title="AWS Credential Manager", subtitle="Select a profile ", strings=menu)]) | |
| except: | |
| exit(1) | |
| ## config file | |
| AWS_CRED_FILE='/home/user/.aws/credentials' | |
| config, menu=load_config(AWS_CRED_FILE) | |
| profile = show_menu(menu) | |
| config['default']['aws_access_key_id'] = config[profile]['aws_access_key_id'] | |
| config['default']['aws_secret_access_key'] = config[profile]['aws_secret_access_key'] | |
| with open(AWS_CRED_FILE, 'w') as configfile: | |
| config.write(configfile) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A simple menu driven script to manage aws credentials profiles.