Skip to main content

Avatar

Build Status Code Scanning Status Dependencies Status Security Status Published Version

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.

Custom command

If you need to run a custom command using each profile, you can use the _ (underscore) character which will tell mpaws to run the custom command AS-IS.

Here's an example:

export MPAWS_PROFILES=profile1,profile2,profile3
export MPAWS_REGIONS=us-east-1,ap-southeast-2
mpaws _ echo \$\{AWS_PROFILE\} \$\{AWS_REGION\}

Which will run the custom command against the permutation of the AWS profiles and AWS regions:

AWS_PROFILE=profile1 AWS_DEFAULT_REGION=us-east-1 AWS_REGION=us-east-1 echo \$\{AWS_PROFILE\} \$\{AWS_REGION\}
AWS_PROFILE=profile1 AWS_DEFAULT_REGION=ap-southeast-2 AWS_REGION=ap-southeast-2 echo \$\{AWS_PROFILE\} \$\{AWS_REGION\}
AWS_PROFILE=profile2 AWS_DEFAULT_REGION=us-east-1 AWS_REGION=us-east-1 echo \$\{AWS_PROFILE\} \$\{AWS_REGION\}
AWS_PROFILE=profile2 AWS_DEFAULT_REGION=ap-southeast-2 AWS_REGION=ap-southeast-2 echo \$\{AWS_PROFILE\} \$\{AWS_REGION\}
AWS_PROFILE=profile3 AWS_DEFAULT_REGION=us-east-1 AWS_REGION=us-east-1 echo \$\{AWS_PROFILE\} \$\{AWS_REGION\}
AWS_PROFILE=profile3 AWS_DEFAULT_REGION=ap-southeast-2 AWS_REGION=ap-southeast-2 echo \$\{AWS_PROFILE\} \$\{AWS_REGION\}

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

Developer's Guide

Build reports:

Metadata

Release files for mpaws 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mpaws 1.1.1
File Size Uploaded
mpaws-1.1.1.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mpaws 1.1.1
File Interpreter ABI Platform
mpaws-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.2 kB

Release files / mpaws-1.1.1.tar.gz

Download URL mpaws-1.1.1.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
15f5fa58719f6655575fa03d3a905cc9d44ddab6ac16a47789af18d0cbdfa646
BLAKE2b-256 checksum
How to use checksums
79123a4822c6f9dd8b8900c2aba7e5091e2f37230068326cba9c1ce2d5b10ba6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / mpaws-1.1.1-py3-none-any.whl

Download URL mpaws-1.1.1-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ba71d72fbb00b75e5d04b7e27f3c40e5a815ce57fe4ab2f4c6561d3feff56de
BLAKE2b-256 checksum
How to use checksums
14f62ba28a276a087f36a993b4a7416d77ba41bf91bd59c0402a47869ee7d0bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page