Skip to main content

Assume an AWS IAM role from AWS API credentials in environment variables

Project description

https://img.shields.io/pypi/v/envassume.svg https://img.shields.io/pypi/pyversions/envassume.svg https://img.shields.io/pypi/l/envassume.svg https://travis-ci.org/wamonite/envassume.svg?branch=master https://codecov.io/gh/wamonite/envassume/branch/master/graph/badge.svg

Assume an AWS IAM role from AWS API credentials in environment variables and execute a command with the assumed credentials (similar to envdir).

envassume takes the effort out of assuming an AWS role from the command-line and copying/pasting the returned credentials into environment variables to run a script. If you often need to do this:-

$ aws sts assume-role --role-arn arn:aws:iam::123456789012:role/s3_access --role-session-name s3_access_session
{
    "AssumedRoleUser": {
        "AssumedRoleId": "xxxxxxxxxxxxxxxxxxxxx:s3_access_session",
        "Arn": "arn:aws:sts::123456789012:assumed-role/s3_access/s3_access_session"
    },
    "Credentials": {
        "SecretAccessKey": "mmm",
        "SessionToken": "nnn",
        "Expiration": "2019-02-26T00:00:00Z",
        "AccessKeyId": "ooo"
    }
}
$ AWS_ACCESS_KEY_ID='ooo' AWS_SECRET_ACCESS_KEY='mmm' AWS_SESSION_TOKEN='nnn' aws s3 ls

It can be shortened to:-

$ envassume arn:aws:iam::123456789012:role/s3_access aws s3 ls

Useful if you often need to test roles, or run scripts with assumed roles on AWS instances using credentials from the instance profile.

Install

pip install envassume

Usage

usage: envassume [-h] [-i EXTERNAL_ID] [ARN] command [argument [argument ...]]

optional arguments:
    -h, --help              show this help message and exit
    -i, --id EXTERNAL_ID    external id
    ARN                     AWS role ARN to assume (required if not set by environment variable)

environment variables:
    environment must contain valid AWS API credentials

    AWS_ASSUME_ROLE=ARN
        no options can be present before the command if this is defined

    AWS_ASSUME_ID=EXTERNAL_ID

License

Copyright (c) 2017 Warren Moore

This software may be redistributed under the terms of the MIT License. See the file LICENSE for details.

Contact

      @wamonite     - twitter
       \_______.com - web
warren____________/ - email

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

envassume-1.0.5.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

envassume-1.0.5-py2.py3-none-any.whl (6.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file envassume-1.0.5.tar.gz.

File metadata

  • Download URL: envassume-1.0.5.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.13

File hashes

Hashes for envassume-1.0.5.tar.gz
Algorithm Hash digest
SHA256 7136f848fe6e781bf7c5b835432d33315793e1f15911c1d4e256e410ba5bd5f3
MD5 0a93ef5c362947d79b56d1b79d33b48b
BLAKE2b-256 4f3134828c2dc14b0204f0a93cc2ee57d42bca21c23d4d7bab5e70fee20cc9f0

See more details on using hashes here.

File details

Details for the file envassume-1.0.5-py2.py3-none-any.whl.

File metadata

  • Download URL: envassume-1.0.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.13

File hashes

Hashes for envassume-1.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6a69b964bf1ff3450fcde2ec6b59e9afc6453f0dd750440fc40558f342abccfe
MD5 59ccbc274e7be201b30443875372e1a9
BLAKE2b-256 e084f19cdd3c4e246c9cab3860e2b2503878810b09676097d0eff802a33de61d

See more details on using hashes here.

Supported by

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