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を使った複数のプログラムで共有して利用することができます。

Usage

1. Create Instance

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': 有効期限,
}

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-0.0.1.tar.gz (4.7 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-0.0.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for aws_sso_credential_helper-0.0.1.tar.gz
Algorithm Hash digest
SHA256 6abfa9de5444898762c6ffd731a29d7402ae4788fe7e5f201448d53d843b2d6a
MD5 38a7a8012a0611a6471b08717044acc6
BLAKE2b-256 05e7de9e0c9c16baa3339d4b122e2c216ec7361c35cc498a11bcfa516ac71752

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aws_sso_credential_helper-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 51c17d60a8ddf5bf128177ccf37da9d46f04d613f8a384ed0d148f8394792713
MD5 acaff58394e06bf1c58b6b71205d604f
BLAKE2b-256 7e102f9f7c97408677c80943d50905d115d05e748604c1b1f2640f890964d065

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