Skip to main content

AWS cli assume role and Okta authentication.

Project description

pyokta-aws-cli-assume-role

pypi version pypi downloads source build License: GPL v3


Okta-AWS auth tool for humans

If you login to AWS via Okta SAML federation and assume an IAM role, this tool will help you easily achieve pragmatic access to AWS via the aws cli and SDKs. Also helpful for running terraform/terragrunt, packer, and credstash with iam roles.

Replaces okta-aws-cli-assume-role

NOTICE: This project is still in rapid development phase. You can subscribe to new release notifications via github. Upgrade to the most recent release via pip install --upgrade --no-cache-dir pyokta-aws-cli-assume-role.

Table of Contents

Support

  • MFA: SMS
  • MFA: Okta mobile app
  • All major operating systems (Linux, Windows, Mac).

Please create an issue for bugs or feature requests (if not already mentioned in roadmap or other issues).

Why a new tool?

Benefits over existing tool

  • No PATH changes or overriding aws executables - you're still using native awscli.
  • Supports multiple tenants.
  • One consistent config file for all tenants.
  • Env var changes are 100% optional.
  • Cleaner https error output.
  • Easy to install.
  • JVM not required.

Existing tool features missing in this tool

These features are planned to be supported in the near future. See roadmap.

  • Interactively select from multiple mfa options.
  • Set desired mfa option via cli args, env vars, or config file.
  • Support Okta mobile app mfa (currently only sms is verified to work).
  • Cross-OS compatibility
  • Okta token caching/refresh.

Getting Started

Requirements

  • python 3.5+
  • pip
  • awscli: pip install --upgrade awscli

Install

pip install --upgrade --no-cache-dir pyokta-aws-cli-assume-role


To check the install and output the current version, run: pyokta-aws --version

Configure

Configuration can be input via cli args, env vars, or the pyokta-aws config file described above. Configuration takes presidence as follows: cli args > env vars > config file. For all supported args and env vars, run pyokta-aws --help and pyokta-aws [COMMAND] --help.

Interactive

Run pyokta-aws configure for interactive configuration (WIP).

Config file

Default configuration file location is ~/.pyokta_aws/config.

Example config file:

[my-aws-profile]
region = us-east-1
okta_org = example.okta.com
okta_aws_app_url = https://example.okta.com/home/amazon_aws/123456789
aws_role_to_assume = arn:aws:iam::987654321:role/AWSAdmin
aws_idp = arn:aws:iam::987654321:saml-provider/Okta
username = johnsmith
sts_duration = 14400
mfa_choice = sms
  • region: Target AWS region. (Will override default region in target aws cli profile)
  • okta_org: Base domain for okta org.
  • okta_aws_app_url: Okta app url (can be found by hovering over aws app chiclet).
  • aws_role_to_assume: Found in AWS console under IAM > Roles > <role_id>. Look for ARN.
  • aws_idp: Found in AWS console under IAM > Identity Providers > <provider_id>. Look for ARN.
  • username: (optional) Okta username.
  • password: (optional) it is recommended to omit or leave it blank and enter it interactively.
  • sts_duration: (optional) Duration (in seconds) to keep token alive. Max duration found in IAM > Identity Providers > <provider_id>.
  • mfa_choice: (optional) If you have multiple MFA factors registered, you can skip interactive factor selection by setting preferred mfa choice. Current options are sms and app (i.e. Okta mobile app).

Usage

To authenticate via okta and assume an aws profile, run:

pyokta-aws auth --profile <aws_profile>


For all supported auth args, run pyokta-aws auth --help.

For all supported commands, run pyokta-aws --help.

How it works

The main pyokta-aws auth command authenticates with Okta and aquires a temporary set of credentials from AWS STS. These credentials get written to you local aws credentials file. This allows the aws cli and other tools like terraform/terragrunt, packer, and credstash to run as expected without needing to override the awscli executable or export environment variables.

Before auth happens, your local aws cli config profile is updated via the profile and region set in the pyokta-aws config. Treat you pyokta-aws config file as the single source of truth for aws cli config when authenticating with Okta.

Roadmap

  • pypi package
  • cli and settings loaders
  • support multi-tenant settings
  • ci (testing) :construction_worker:
  • okta auth
  • okta 2fa (sms)
  • get saml from okta app
  • aws auth via okta auth
  • aws config if not previously setup
  • basic documentation :pencil:
  • support multiple 2fa methods
  • interactive initial config :children_crossing:
  • readthedocs :pencil:
  • many more tests
  • windows support :checkered_flag:
  • ci/cd (deploy to pypi)?
  • aws role list selection in interactive mode :children_crossing:
  • okta 2fa (okta mobile app)
  • push notification 2fa
  • use context managers to auto-cancel okta verifications on cancel
  • okta token cache/refresh to speedup multiple logins :children_crossing:

:dog:

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

pyokta-aws-cli-assume-role-0.2.2.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

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

pyokta_aws_cli_assume_role-0.2.2-py2.py3-none-any.whl (29.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pyokta-aws-cli-assume-role-0.2.2.tar.gz.

File metadata

  • Download URL: pyokta-aws-cli-assume-role-0.2.2.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for pyokta-aws-cli-assume-role-0.2.2.tar.gz
Algorithm Hash digest
SHA256 b8a00035b1be0af7d1a06ab243ca2278d73e771bc590731110c948df2e0edb28
MD5 fcb4ef0bbc557d1b68f5d6faaf444eed
BLAKE2b-256 987189d0a1845494b45b6507bc5ed946920ca2b40ac3db9e1894d12ab34e6c94

See more details on using hashes here.

File details

Details for the file pyokta_aws_cli_assume_role-0.2.2-py2.py3-none-any.whl.

File metadata

  • Download URL: pyokta_aws_cli_assume_role-0.2.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 29.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for pyokta_aws_cli_assume_role-0.2.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a46d246647f46a9bd424ed66ff6ec0d1af33d92bffc3ed2a029b5f0765542649
MD5 2bb9dad524cdd862c0c04f2e69a9e033
BLAKE2b-256 78c79189c51df3f7b10f506d7abc53e6a9e273b2063bca252dc17c61e7cb5be5

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