Skip to main content

Switching between multiple AWS accounts & renewing API access keys

Project description

PyPI

This package provides scripts for:

  • switching between multiple AWS accounts

  • renewing AWS API access keys

Installation

The easiest way to install aws-tools is to use pip:

in your home directory:

pip install --user aws-tools

inside a virtualenv:

pip install aws-tools

or system-wide:

sudo pip install aws-tools

This will install aws-tools package as well as all dependencies

Getting started

AWS configuration

Before using aws-tools you have to configure your AWS environments and credentials:

$ cat .aws/env.test.conf
[default]
aws_access_key_id = <your_access_key>
aws_secret_access_key = <your_secret_access_key_id>

The same goes for the other environments, for example: stage and production.

Encrypt all of the files with gpg:

gpg --encrypt --armor --output env.test.conf.asc -r <your-gpg-user-id-name> env.test.conf
gpg --encrypt --armor --output env.stage.conf.asc -r <your-gpg-user-id-name> env.stage.conf
gpg --encrypt --armor --output env.production.conf.asc -r <your-gpg-user-id-name> env.production.conf

and remove temporary files (env*conf).

SMTP configuration (-s and -i) (optional)

In the .aws directory:

smtp.cfg (temporary file):

smtplogin = <full_smtp_login>
smtppass = <password>
smtphost = <smtp_host>
smtpport = <smtp_port>

Ecrypt it:

gpg --encrypt --armor --output smtp.cfg.asc -r <your-gpg-user-id-name> smtp.cfg

And remove temporary file (smtp.cfg)

Shell configuration (optional)

Add to .bashrc.

  • Command Completion

The aws-tools comes with a very useful bash command completion feature. This feature isn’t automatically installed, so you need to enable it yourself. Simply add to your .bashrc:

if you have installed aws-tools in home directory:

source $HOME/.local/bin/aws_tools_completion.bash

if you have installed aws-tools system-wide:

source /usr/local/bin/aws_tools_completion.bash
  • Functions

It is also handy to add some bash functions:

function awsenv() {
    __aws_env_update -x -a -e $1
}

function awsroll() {
    __aws_roll_keys -a -s <youremail@domain.com> -i <groupemail@domain.com> -e "${1:-all}"
}
  • Displaying current account in your shell

add to $PS1 variable:

$(__awsenv_ps1)

Usage

Examples

Switch to test account and write credentials to .aws/credentials file:

$ aws-env-update.py -a -e test

Switch to test account using shell variables:

$ eval $(aws-env-update.py -a -e test -x)

The same, but after sourcing aws_tools_completion.bash:

$ awsenv test

Rotating AWS API keys for stage account:

$ aws-roll-keys.py -a -e stage

Rotating AWS API keys for production account and sending the new keys to you:

$ aws-roll-keys.py -a -e production -s <youremail@domain.com>

Rotating AWS API keys for all of environments and sending confirmation to the group:

$ aws-roll-keys.py -a -e all -i <groupemail@domain.com>

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

aws-tools-1.0.20.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_tools-1.0.20-py2.py3-none-any.whl (9.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file aws-tools-1.0.20.tar.gz.

File metadata

  • Download URL: aws-tools-1.0.20.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aws-tools-1.0.20.tar.gz
Algorithm Hash digest
SHA256 f82962fd5b5e10d553659fcaf843fb165955918341c0a23663b5cd86a0600e7e
MD5 8282d66632387ef4413b04fc43e9817c
BLAKE2b-256 4da307783367e8b404a6e3e85ed3d2a5c3d9757b1f5323ba4da5720c4980c552

See more details on using hashes here.

File details

Details for the file aws_tools-1.0.20-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for aws_tools-1.0.20-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6b5d5373643850dc690d5eae69b1d30a46f204ee2c0ac84ffbc38ee71ac63ff8
MD5 b7646124f21e3eaaf5f1fc0276d37350
BLAKE2b-256 d321f7a95fa342cf34d2a3f03622e1d724ab4e55c692a17a5d759945e73b6222

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