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.6

  • 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

If authenticating with SSO:

  • AWS account ID

  • AWS SSO Permission Set (role) name

  • AWS SSO login URL

Usage

Installation:

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

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 = 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>",
)
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>",
)
session = auth.sso()
client = session.client("sts")

response = client.get_caller_identity()
print(response)

Testing profile-based login as a script in BASH:

python [/path/to/]aws_authenticator \
-m profile \
-p <profile-name>

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-2024.1.0.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

aws_authenticator-2024.1.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aws_authenticator-2024.1.0.1.tar.gz
  • Upload date:
  • Size: 2.8 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-2024.1.0.1.tar.gz
Algorithm Hash digest
SHA256 3e9a7b7a406f213f3b6cad21b6e1483257b1d793737266c6c3e01fe71fe14e4e
MD5 cd85d041071d387ea4dd4ba1ea3ba197
BLAKE2b-256 8b0d80ebaae2fb2c1bec67dc5d33558b4648cbd27bce0bcd01c05beaefc29a08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aws_authenticator-2024.1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0c8bb363b0f9efd98d40bc6c9086036e7b56caf1ecea9b2ea356d45bab4133ee
MD5 536c4fcf58ed6637dc0c842a3c6520a8
BLAKE2b-256 c3c6efb305ad8de5fa7f8960a50ada0b09717182b3d4e68962f6232b27eb429e

See more details on using hashes here.

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