Small PowerShell script to automate the process of entering authenticated session tokens to run local aws cli commands. This PowerShell script was based upon a Windows 10 build.
aws cli
already installed- Script assumes aws is installed in default
$USER/.aws
directory
- Script assumes aws is installed in default
- The files from this repo:
- mfa.ps1
- aws_accounts.txt //need to update to your real account id's
- AWS Account Key's
- Assumed Role in AWS
./mfa.ps1
Environment variables need to be stored with the following names:
The values of the variables will match your default aws key's.
- AWS_ACCESS_KEY
- AWS_SECRET_ACCESS_KEY
- AWS_MFA_SERIAL
- Change the line
$ASSUME_ROLE = "MyRoleForCrossAccountAccess"
to your proper assumed role in AWS.
- I hard coded the region for my script to be
us-west-1
Add-Content $AWS_CONFIG "region = us-west-1"
// lines 70 & 100- At the time of this writing, AWS required a region to be set in the config. I may change this in a future update.
Text Formatting As Follows:
555551111222 ## FAKE ACCOUNT 1 ##
123456789012 ## FAKE ACCOUNT 2 ##
The script splits line by line by white space and stores first string into an array for further processing.