Skip to main content

Login to AWS using CLI named profiles, IAM access key credentials, or SSO.

Project description

Overview

Login to AWS using CLI named profiles, IAM access key credentials, or SSO.

Prerequisites

  • Python >= 3.10

  • aws-ssooidc (https://pypi.org/project/aws-ssooidc/) >= 2021.1.1.1

  • boto3 (https://pypi.org/project/boto3/) >= 1.17.78

Conditional Arguments

If authenticating with named profiles:

  • AWSCLI profile name

If authenticating with IAM acccess key credentials:

  • AWS access key id

  • AWS secret access key

  • AWS session token (optional, if using temporary credentials)

If authenticating with SSO:

  • AWS account ID

  • AWS SSO Permission Set (role) name

  • AWS SSO login URL

Additional argument:

  • AWS region (optional)

Usage

Installation:

pip3 install aws-authenticator
# or
python3 -m pip install aws-authenticator

In Python3 authenticating with default profile:

import aws_authenticator

auth = aws_authenticator.AWSAuthenticator()
session = auth.profile()
client = session.client("<service-name>")

In Python3 authenticating with named profiles:

import aws_authenticator

auth = aws_authenticator.AWSAuthenticator(
   profile_name="<profile-name>"
)
session = auth.profile()
client = session.client("<service-name>")

In Python3 authenticating with IAM access key credentials:

import aws_authenticator

auth = aws_authenticator.AWSAuthenticator(
   access_key_id="<access-key-id>",
   secret_access_key="<secret-access-key>",
   session_token="<session-token>"
)
session = auth.iam()
client = session.client("<service-name>")

In Python3 authenticating with SSO:

import aws_authenticator

auth = aws_authenticator.AWSAuthenticator(
   sso_url="<sso-url>",
   sso_role_name="<sso-role-name>",
   sso_account_id="<sso-account-id>",
   region_name="<region-name>"
)
session = auth.sso()
client = session.client("<service-name>")

Testing Examples

Testing SSO-based login in Python3:

import aws_authenticator

auth = aws_authenticator.AWSAuthenticator(
   sso_url="<sso-url>",
   sso_role_name="<sso-role-name>",
   sso_account_id="<sso-account-id>",
   region_name="<region-name>"
)
session = auth.sso()
client = session.client("sts")

response = client.get_caller_identity()
print(response)

Testing profile-based login as a script in BASH:

aws_callerid

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_authenticator-2.0.8.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

aws_authenticator-2.0.8-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file aws_authenticator-2.0.8.tar.gz.

File metadata

  • Download URL: aws_authenticator-2.0.8.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/5.15.154+

File hashes

Hashes for aws_authenticator-2.0.8.tar.gz
Algorithm Hash digest
SHA256 ed8cec86d5ff0ee6bd6a82a96d1592defb88c0cf7df6209eaf90e4dd2ee16b04
MD5 e1643735362b87a485ba85fa6fbf52ce
BLAKE2b-256 71a95795756ec003bb0e83bcb6b7bdc9e1eed7e99790e130ef2dd5009077de5a

See more details on using hashes here.

File details

Details for the file aws_authenticator-2.0.8-py3-none-any.whl.

File metadata

  • Download URL: aws_authenticator-2.0.8-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/5.15.154+

File hashes

Hashes for aws_authenticator-2.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 390131da3f8ec3d12cd43bb60d25e8eb9de3455c16544d2c6b4698cb693d0781
MD5 b90d38e6e5274eda7752ae1942be39c4
BLAKE2b-256 81139e98d7f714cf5d011d9c49f5e61a06f73fded590e6112c54c683fc473074

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