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
Release files for aws_authenticator 2.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aws_authenticator-2.0.8.tar.gz | 3.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aws_authenticator-2.0.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.4 kB
Release files / aws_authenticator-2.0.8.tar.gz
| Download URL | aws_authenticator-2.0.8.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed8cec86d5ff0ee6bd6a82a96d1592defb88c0cf7df6209eaf90e4dd2ee16b04
|
|
BLAKE2b-256 checksum How to use checksums |
71a95795756ec003bb0e83bcb6b7bdc9e1eed7e99790e130ef2dd5009077de5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.3 Linux/5.15.154+
|
Release files / aws_authenticator-2.0.8-py3-none-any.whl
| Download URL | aws_authenticator-2.0.8-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
390131da3f8ec3d12cd43bb60d25e8eb9de3455c16544d2c6b4698cb693d0781
|
|
BLAKE2b-256 checksum How to use checksums |
81139e98d7f714cf5d011d9c49f5e61a06f73fded590e6112c54c683fc473074
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.3 Linux/5.15.154+
|