Skip to content

Simple powershell script to handle AWS STS MFA for AWS command line handling multiple accounts.

License

Notifications You must be signed in to change notification settings

mark-bixler/aws_mfa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

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.

Getting Started

  1. aws cli already installed
    • Script assumes aws is installed in default $USER/.aws directory
  2. The files from this repo:
    • mfa.ps1
    • aws_accounts.txt //need to update to your real account id's
  3. AWS Account Key's
  4. Assumed Role in AWS

Running

./mfa.ps1

Dependencies

mfa.ps1

Environment Variables

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
Assumed Role
  • Change the line $ASSUME_ROLE = "MyRoleForCrossAccountAccess"to your proper assumed role in AWS.
Region
  • 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.

aws_accounts.txt

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.

About

Simple powershell script to handle AWS STS MFA for AWS command line handling multiple accounts.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published