Execute AWS CLI across multiple profiles and multiple regions in one go
Project description
mpaws
mpaws is a Python CLI for running an AWS command across multiple profiles and multiple regions in one go.
This is a time-saver when you are managing dozens of AWS accounts and need to run the same command across all of them.
Installation
pip3 install mpaws
Usage
Set an environment variable MPAWS_PROFILES
, and another environment variable MPAWS_REGIONS
, then run mpaws
command:
export MPAWS_PROFILES=profile1,profile2,profile3
export MPAWS_REGIONS=us-east-1,ap-southeast-2
mpaws ec2 describe-instances
The above command will run aws ec2 describe-instances
command for each permutation of the AWS profiles and AWS regions, like these:
AWS_PROFILE=profile1 AWS_DEFAULT_REGION=us-east-1 AWS_REGION=us-east-1 aws ec2 describe-instances
AWS_PROFILE=profile1 AWS_DEFAULT_REGION=ap-southeast-2 AWS_REGION=ap-southeast-2 aws ec2 describe-instances
AWS_PROFILE=profile2 AWS_DEFAULT_REGION=us-east-1 AWS_REGION=us-east-1 aws ec2 describe-instances
AWS_PROFILE=profile2 AWS_DEFAULT_REGION=ap-southeast-2 AWS_REGION=ap-southeast-2 aws ec2 describe-instances
AWS_PROFILE=profile3 AWS_DEFAULT_REGION=us-east-1 AWS_REGION=us-east-1 aws ec2 describe-instances
AWS_PROFILE=profile3 AWS_DEFAULT_REGION=ap-southeast-2 AWS_REGION=ap-southeast-2 aws ec2 describe-instances
Alternatively, you can also run mpaws
with multiple AWS profiles against a single AWS region. You can do this by setting the environment variable MPAWS_PROFILES
, then run mpaws
command:
export MPAWS_PROFILES=profile1,profile2,profile3
mpaws ec2 describe-instances
The above command will run aws ec2 describe-instances
command using each AWS profile, combined with the configured AWS region (either via AWS_DEFAULT_REGION
, AWS_REGION
, or the configured region within the profile definition).
Here's an example if AWS_DEFAULT_REGION
is specified with us-east-1 as the value:
AWS_PROFILE=profile1 AWS_DEFAULT_REGION=us-east-1 AWS_REGION=us-east-1 aws ec2 describe-instances
AWS_PROFILE=profile2 AWS_DEFAULT_REGION=us-east-1 AWS_REGION=us-east-1 aws ec2 describe-instances-instances
AWS_PROFILE=profile3 AWS_DEFAULT_REGION=us-east-1 AWS_REGION=us-east-1 aws ec2 describe-instances
Note that each run will also carry over the environment variables available from the original mpaws
command run.
Configuration
Ensure that the profiles specified in MPAWS_PROFILES
are already configured in credential file. And the regions specified in MPAWS_REGIONS
, AWS_DEFAULT_REGION
, AWS_REGION
, or AWS configuration are valid regions.
Environment Variable | Mandatory | Example |
---|---|---|
MPAWS_PROFILES | Yes | profile1,profile2,profile3 |
MPAWS_REGIONS | No | us-east-1,ap-southeast-2 |
AWS_DEFAULT_REGION | No | us-east-1 |
AWS_REGION | No | us-east-1 |
Colophon
Build reports:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mpaws-0.11.0.tar.gz
.
File metadata
- Download URL: mpaws-0.11.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/6.2.0-1014-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edce3f5d39724090d4437fdaf5ea1317ca2804c5b2f84193bfce45a18482fa21 |
|
MD5 | 50b0b2a11ba04823bf884d3a382da985 |
|
BLAKE2b-256 | bc6c80b4f67b3fd2cdd20fd9829e666440415537af73099e343cb83512776740 |
File details
Details for the file mpaws-0.11.0-py3-none-any.whl
.
File metadata
- Download URL: mpaws-0.11.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/6.2.0-1014-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42a48c55fc44d9ba06c4a46e3ff901b52255ed8bcee69b309fb3201b4e3eea80 |
|
MD5 | aa0df6b4f45f724bf42db0600f66028f |
|
BLAKE2b-256 | 330860672b6eae0861fcf18ccc5d8d68c68b405a051bef23e1ecfb962ff8f8d9 |