Skip to main content

AWS SSO Credential Helper

AWSの認証を、AWS SSO (IAM Identity Center)を使って組織のユーザーディレクトリと連携されているケースは多いのではないでしょうか。
また、SSOでの認証後、各プロダクト・プロジェクト毎の専用ロールへスイッチロールが必要な場合も多いかと思います。

AWS SSO Credential Helperは、AWS SSOを通した認証と、その後のスイッチロールでの一時認証情報の取得を助けます。

実行時には、必要に応じてブラウザにて認証確認を求められますので、許可して下さい。
AWS SSOの認証tokenはファイルにキャッシュし、有効期間内であれば再利用します。
また、キャッシュはホームディレクトリにファイルとして保存し、Credential Helperを使った複数のプログラムで共有して利用することができます。

Pypi

https://pypi.org/project/aws-sso-credential-helper/

Usage

1. Create Instance

from aws_sso_credential_helper import CredentialHelper

credential_helper = CredentialHelper(
    start_url="d-xxxxxxxxxx.awsapps.com/start",
    region_name="ap-northeast-1"
    )
  • start_url : AWSアクセスポータルのURL
  • region_name : 対象とするIAM Identity Centerのリージョン

2. Get Credentials

credentials = credential_helper.get_swrole_credentials(
    sso_account_id="123456789",
    sso_role_name="ssoRoleName",
    sw_role_arn="arn:aws:iam::123456789012:role/sw-role-name"
    )
  • sso_account_id : アクセスポータルのあるAWSアカウントID
  • sso_role_name : SSOでログインするロール
  • sw_role_arn : SSOでログイン後、スイッチロールする先のロールのARN

3. Create boto3 client with credentials

lambda_client = boto3.client(
    "lambda",
    region_name="ap-northeast-1",
    aws_access_key_id=credentials["AccessKeyId"],
    aws_secret_access_key=credentials["SecretAccessKey"],
    aws_session_token=credentials["SessionToken"],
    )

Credentials

{
    'AccessKeyId': 'XXXXXXXXXXXXX',
    'SecretAccessKey': 'YYYYYYYYY',
    'SessionToken': 'ZZZZZZZZZZ',
    'Expiration': 有効期限,
}

How to install

install from pypi

pip install aws-sso-credential-helper

Metadata

Release files for aws-sso-credential-helper 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aws-sso-credential-helper 1.0.0
File Size Uploaded Provenance Actions
aws_sso_credential_helper-1.0.0.tar.gz 4.8 kB Without provenance Details for aws_sso_credential_helper-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aws-sso-credential-helper 1.0.0
File Interpreter ABI Platform Actions
aws_sso_credential_helper-1.0.0-py3-none-any.whl Python 3 none any Details for aws_sso_credential_helper-1.0.0-py3-none-any.whl

Total release size: 10.2 kB

Release files / aws_sso_credential_helper-1.0.0.tar.gz

Download URL aws_sso_credential_helper-1.0.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a2f690db3d04bb16c7f50273cb57534f820b148dfb2d070393207058d5fa9725
BLAKE2b-256 checksum
How to use checksums
874dd444c4be66b0d0886b16f5ebb8a6b1b589d3afb5c7b5993f16710ee91342
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / aws_sso_credential_helper-1.0.0-py3-none-any.whl

Download URL aws_sso_credential_helper-1.0.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9b69de904722cd0a658f3fba6f28f01acebfd7f3d333a3f750d0ac83c5e95344
BLAKE2b-256 checksum
How to use checksums
a773c707c8ace9304e264a0106d4a2e30f72e92a9b3bca741f768c6d7a36f2af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Security for aws-sso-credential-helper 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page