AwsUse is a simple PowerShell utility that lets you switch between multiple AWS accounts from the command line with ease. It gives you quick access to 3 handy commands:
awsuse select <profile>β Set the selected profile as the current default AWS account.awsuse whoamiβ Print the name of the currently active AWS profile.awsuse listβ List all available AWS profiles defined in the script.
git clone https://github.com/FazlOmar9/AwsUse.git
Important: You need both files: awsuse.ps1 and awsuse.cmd
The .ps1 script does the work, and the .cmd file lets you call awsuse easily from any terminal.
Open awsuse.ps1 in a text editor and find this section:
$accounts = @{
"account1" = @{
aws_access_key_id = "YOUR_KEY"
aws_secret_access_key = "YOUR_SECRET"
default_region = "ap-south-1"
}
"account2" = @{
aws_access_key_id = "YOUR_KEY"
aws_secret_access_key = "YOUR_SECRET"
default_region = "ap-south-1"
}
}
- Replace the values with your own access keys and regions.
- Add or remove accounts as needed β the key names like
"account1"or"account2"are the profile names youβll use withawsuse select.
To use awsuse from any PowerShell or CMD window:
-
Keep both
awsuse.ps1andawsuse.cmdin a permanent folder (e.g.,C:\Scripts\). -
Add that folder to your system
PATH:- Press
Win + S, search for "Environment Variables". - Edit the System variables section β Find and edit the
Pathvariable. - Add the path to the folder (e.g.,
C:\Scripts).
- Press
-
Restart your terminal.
Now you can run awsuse from anywhere like this:
awsuse select account1
awsuse select account2 --region ap-south-1
awsuse whoami
awsuse list
- When you
selectan account, it overwrites your default AWS config (~/.aws/credentialsand~/.aws/config) with the selected accountβs keys and region. - This way, the AWS CLI and SDKs will always use that account without requiring a
--profileflag.
- No need to remember or export environment variables.
- No need to pass
--profileto every CLI command. - Easy to switch accounts persistently from any PowerShell session.
This tool stores AWS credentials in plain text within the script file. Use with caution and avoid committing sensitive keys to GitHub.
MIT License β do what you want, but don't blame me if you break something. π