Execute a command using an AWS assumed role
Project description
A command to provide a friendly way to do an AWS STS assumeRole operation so you can perform AWS API actions using a particular set of permissions. Includes integration with roles requiring MFA authentication! Works off of profile names configured in the AWS SDK configuration file.
Just like the awscli, this utility will cache the assumed role credentials. If using MFA, when the credentials expire you will be prompted to re-enter the MFA token value to refresh the credentials. If MFA is not required for the assumed role, the credentials should refresh automatically.
See the following for more information on AWS SDK configuration files:
http://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html
https://boto3.readthedocs.io/en/latest/guide/quickstart.html#configuration
https://boto3.readthedocs.io/en/latest/guide/configuration.html#aws-config-file
Requirements
Tested on python 2.7 and python 3
boto3 python library, version 1.3.1 or higher
Installation
Using pip is the preferred method to install this tool, and will install the package from pypi. pip install aws-cli
It can also be installed via pip from a local copy of the source repo, pip install . from the repo directory should do the trick.
Usage
Listing available roles
Use the -l option to see the list of role ARNs your IAM account is authorized to assume. May be helpful for setting up your AWS config file.
Generating credentials
Running the program with only a profile name will output an eval()-able set of environment variable which can be added to the current session.
Example:
Or simply eval $(aws-runas admin-profile) to add these env vars in the current session
Running command using a profile
Running the program specifying a profile name and command will execute the command using the profile credentials, automatically performing any configured assumeRole operation, or MFA token gathering.
Example (run the command aws s3 ls using the profile admin-profile):
Running command using the default profile
Running the program using the default profile is no different than using a custom profile, simply use default as the profile name.
Contributing
The usual github model for forking the repo and creating a pull request is the preferred way to contribute to this tool. Bug fixes, enhancements, doc updates, translations are always welcomed.
Building from source
A Makefile has been included in the repository to handle the steps of creating the package and uploading it to pypi. If you don’t have the make utility installed, the contents of the Makefile should be instructive (and simple) enough to execute manually.
The following targets are available in the Makefile:
package - the default target, calls the setup.py script to create the package to upload to pypi.
upload - depends on the package target, and uploads the generated package archive to pypi.
clean - clean up the artifacts left by the package step.
distclean - depends on the clean target, and additionally cleans up misc. files.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for aws_runas-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d64796cac020e3a31dac84945749bdf5d53fd71334fbff36cdc2871f3a5acfcd |
|
MD5 | 2ba88d54a8a25c69e91194364a236b6d |
|
BLAKE2b-256 | 6af849e56b124a7f0f149049c7fbf852f2de4b724912a62882da2a8b593b35fd |