Skip to main content

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.

Installation

  • pip install with_aws_config

  • pip show with-aws-config -f

  • Ensure with-aws-config is on your PATH

Usage

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

Positional arguments

COMMAND

the command to run, e.g. ec2-describe-instances, aws, or ansible

ARGUMENT

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

Behaviour

with-aws-config:

You have three ways to specify the profile:

Examples

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

Input

  • 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

Output

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

The following environment variables will be removed:

  • AWS_CONFIG_FILE

  • AWS_DEFAULT_PROFILE

  • AWS_PROFILE

  • AWS_SESSION_TOKEN

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

  • AWS_ACCESS_KEY

  • AWS_ACCESS_KEY_ID

  • AWS_DEFAULT_REGION

  • AWS_SECRET_ACCESS_KEY

  • AWS_SECRET_KEY

  • 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.

Source Distribution

with_aws_config-1.0.4.tar.gz (5.1 kB view details)

Uploaded Source

File details

Details for the file with_aws_config-1.0.4.tar.gz.

File metadata

File hashes

Hashes for with_aws_config-1.0.4.tar.gz
Algorithm Hash digest
SHA256 7920699f3f84a4d7d53f2fbb03e0e249faeefd687703c3290ba45a18a62c678b
MD5 fb3581eecfd2c612c10478492f6276da
BLAKE2b-256 936f6eb38184d953919cd79820572a391369a719a4c4271414417fdd21dc6742

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page