Skip to main content

Generate temporary login link and envvars for AWS IAM Role

Project description

Easy login to AWS through the command-line.

The project assumes you have:

  1. An IAM account and credentials present in your environment (e.g. ~/.aws/credentials)
  2. Permissions for the IAM account to assume a given role
  3. The name of the role you want to assume

With the above in place you can get temporary credentials and a web UI login link, granting you all of the powers of the assumed role by running:

$ awsrole MyRole
# Export following vars in your shell for API/CLI access:
    export AWS_ACCESS_KEY_ID=ASI...
    export AWS_SECRET_ACCESS_KEY=10q2I...
    export AWS_SESSION_TOKEN=Fwo......

## Login URL: https://signin.aws.amazon.com/federation?Action=login......

Clicking on/opening the URL in the browser will land you in a preauthenticated session. Copy/pasting the export commands in your shell would enable CLI utilities from using the role's credentials.

The temporary credentials would be valid for up to 12h (max and default value)

Installation

pip install awsrole

Help

$ awsrole --help
usage: awsrole [-h] [-a ACCOUNT] [-t TIME] role

Generate temporary credentials and Login URL for a given AWS role.

positional arguments:
  role                  Role to assume

optional arguments:
  -h, --help            show this help message and exit
  -a ACCOUNT, --account ACCOUNT
                        Specify an account ID, instead of auto-discovering it
  -t TIME, --time TIME  Temp credentials validity in seconds (default: 43200)

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

awsrole-0.0.2.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distribution

awsrole-0.0.2-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

Supported by

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