The IAM Role Injector is a tool for easily assuming an IAM Role with Multi-Factor Authentication (MFA). It manipulates environment variables to allow codebases already using AWS credentials to use IAM roles with minimal to no refactoring. In the same vein, the Role Injector can also be used to help users using the command line tools to assume a role.
source assume_role.sh {accountNumber} {mfaAccountNumber} {rolename} {username}
Calling the script with 'source' is required for the environment variables to persist past the runtime of the script.
The script will also protect your original credentials if you chose to store them as environment variables.
Please report any bugs to: https://github.com/civisanalytics/iam-role-injector/issues
Open an issue or a pull request if you see how we can improve the script!