This Python script allows you to get temporary AWS credentials using Multi-Factor Authentication (MFA).
Before using this script, make sure you have the following:
- An AWS account
- AWS credentials with permissions to perform the get_session_token operation
- An MFA device assigned to your IAM user
- The ARN of the MFA device
- pip install boto (if it dosent exist)
- Save the code as get_aws_temp_credentials.py.
- Open the command line interface.
- Navigate to the directory containing get_aws_temp_credentials.py.
- Run the command python get_aws_temp_credentials.py.
- Enter the MFA code when prompted.
- The script will output the temporary AWS credentials that you can use to access AWS resources.
- Copy and paste the printed values (They are exported as an ENV var)
Note: Make sure to replace and with your actual account ID and MFA device name, respectively, in the mfa_serial_number parameter.