Skip to main content

No project description provided

Project description

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

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_sso_credential_helper-1.0.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

aws_sso_credential_helper-1.0.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file aws_sso_credential_helper-1.0.0.tar.gz.

File metadata

File hashes

Hashes for aws_sso_credential_helper-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a2f690db3d04bb16c7f50273cb57534f820b148dfb2d070393207058d5fa9725
MD5 6f134e1dde17f816f22c92e7c18d1a51
BLAKE2b-256 874dd444c4be66b0d0886b16f5ebb8a6b1b589d3afb5c7b5993f16710ee91342

See more details on using hashes here.

File details

Details for the file aws_sso_credential_helper-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aws_sso_credential_helper-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9b69de904722cd0a658f3fba6f28f01acebfd7f3d333a3f750d0ac83c5e95344
MD5 dc1a3405f8e84b00e0688d3430e72a42
BLAKE2b-256 a773c707c8ace9304e264a0106d4a2e30f72e92a9b3bca741f768c6d7a36f2af

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