Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

Set AWS envars from `aws configure`, then run a command.

Project description

Set AWS environment variables from the configuration files maintained by aws configure, then run a command.


  • pip install with_aws_config
  • pip show with-aws-config -f
  • Ensure with-aws-config is on your PATH


with-aws-config [-h] [--verbose] [--profile PROFILE] COMMAND [ARGUMENT ...]

Positional arguments

the command to run, e.g. ec2-describe-instances, aws, or ansible
the command’s arguments, e.g. iam get-user

If any arguments are options, specify -- before the command to end with-aws-config’s optional argument parsing.

Optional arguments

-h, --help
show this help message and exit
--verbose, -v
output debugging information to stderr
--profile PROFILE, -p PROFILE
set the profile, ignoring any environment variables



You have three ways to specify the profile:


Run a command:

with-aws-config -- aws iam get-user
with-aws-config -- ec2-list-instances
with-aws-config -- ansible-playbook setup-vpc.yaml

Specify a profile as an option:

with-aws-config --profile=default -- ec2-describe-instances

Specify a profile via the environment:

env AWS_DEFAULT_PROFILE=default with-aws-config -- ec2-describe-instances

Note we’ve used -- in each to force the end of the optional arguments.

Environment Variables


  • AWS_PROFILE is used to specify profile if --profile is not given
  • AWS_DEFAULT_PROFILE is used if AWS_PROFILE is not set
  • HOME is required to locate $HOME/.aws


COMMAND will be run with the environment supplied to with-aws-config, with the following exceptions:

The following environment variables will be removed:


The following environment variables will be set based on the AWS profile:

  • EC2_URL

AWS_DEFAULT_REGION and EC2_URL will default to point to us-west-2 if not configured during aws configure.

Why this many?

  • aws, boto, and ansible need AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_DEFAULT_REGION
  • ec2-* need AWS_ACCESS_KEY, AWS_SECRET_KEY, and EC2_URL

Exit Status

with-aws-config exits with either:

  • The exit status of COMMAND or, if it can’t be run:
  • One of the following status codes indicating why:
    124:no configuration files found
    125:no configuration section found for the requested profile
    127:command not found
    130:interrupted by user with ^C

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for with_aws_config, version 1.0.4
Filename, size File type Python version Upload date Hashes
Filename, size with_aws_config-1.0.4.tar.gz (5.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page