AWS SAM パイプラインで OIDC 認証を使用する方法 - AWS Serverless Application Model

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

AWS SAM パイプラインで OIDC 認証を使用する方法

AWS Serverless Application Model (AWS SAM) は、Bitbucket、アクション、 GitHub継続的インテグレーションおよび GitLab 継続的デリバリー (CI/CD) プラットフォームの OpenID Connect (OIDC) ユーザー認証をサポートしています。このサポートにより、これらのプラットフォームのいずれかから認証された CI/CD ユーザーアカウントを使用して、サーバーレスアプリケーションパイプラインを管理できます。それ以外の場合は、 AWS SAM パイプラインへのアクセスを制御するために複数の AWS Identity and Access Management (IAM) ユーザーを作成および管理する必要があります。

AWS SAM パイプラインで OIDC をセットアップする

sam pipeline bootstrap 設定プロセス中に、次の操作を実行して AWS SAM パイプラインで OIDC を設定します。

  1. ID プロバイダーの選択を求められたら、OIDC を選択します。

  2. 次に、サポートされている OIDC プロバイダーを選択します。

  3. OIDC プロバイダーの URL を入力します (https:// から入力します)。

    注記

    AWS SAM はAWS::IAM::OIDCProvider、リソースタイプを生成するときにこの URL を参照します。

  4. 次に、プロンプトに従い、選択したプラットフォームへのアクセスに必要な CI/CD プラットフォーム情報を入力します。これらの詳細はプラットフォームによって異なり、次のものが含まれる場合があります。

    • OIDC クライアント ID。

    • コードリポジトリ名または一意の識別子 (UUID)。

    • リポジトリに関連付けられたグループまたは組織名。

    • GitHub コードリポジトリが属する組織。

    • GitHub リポジトリ名。

    • デプロイ元のブランチ。

  5. AWS SAM は、入力された OIDC 設定の概要を表示します。設定の番号を入力して編集するか、Enter を押して続行します。

  6. 入力した OIDC 接続をサポートするために必要なリソースの作成を確認するメッセージが表示されたら、Y を押して続行します。

AWS SAM は、パイプライン実行ロールを引き受ける指定された設定で AWS::IAM::OIDCProvider AWS CloudFormation リソースを生成します。この AWS CloudFormation リソースタイプの詳細については、AWS CloudFormation ユーザーガイドの「AWS::IAM::OIDCProvider」を参照してください。

注記

ID プロバイダー (IdP) リソースが にすでに存在する場合 AWS アカウント、 AWS SAM は新しいリソースを作成する代わりにそれを参照します。

以下は、 AWS SAM パイプラインで OIDC を設定する例です。

Select a permissions provider:
    1 - IAM (default)
    2 - OpenID Connect (OIDC)
Choice (1, 2): 2
Select an OIDC provider:
    1 - GitHub Actions
    2 - GitLab
    3 - Bitbucket
Choice (1, 2, 3): 1
Enter the URL of the OIDC provider [https://token.actions.githubusercontent.com]:
Enter the OIDC client ID (sometimes called audience) [sts.amazonaws.com]:
Enter the GitHub organization that the code repository belongs to. If there is no organization enter your username instead: my-org
Enter GitHub repository name: testing
Enter the name of the branch that deployments will occur from [main]:

[3] Reference application build resources
Enter the pipeline execution role ARN if you have previously created one, or we will create one for you []:
Enter the CloudFormation execution role ARN if you have previously created one, or we will create one for you []:
Please enter the artifact bucket ARN for your Lambda function. If you do not have a bucket, we will create one for you []:
Does your application contain any IMAGE type Lambda functions? [y/N]:

[4] Summary
Below is the summary of the answers:
    1 - Account: 123456
    2 - Stage configuration name: dev
    3 - Region: us-east-1
    4 - OIDC identity provider URL: https://token.actions.githubusercontent.com
    5 - OIDC client ID: sts.amazonaws.com
    6 - GitHub organization: my-org
    7 - GitHub repository: testing
    8 - Deployment branch: main
    9 - Pipeline execution role: [to be created]
    10 - CloudFormation execution role: [to be created]
    11 - Artifacts bucket: [to be created]
    12 - ECR image repository: [skipped]
Press enter to confirm the values above, or select an item to edit the value:

This will create the following required resources for the 'dev' configuration:
    - IAM OIDC Identity Provider
    - Pipeline execution role
    - CloudFormation execution role
    - Artifact bucket
Should we proceed with the creation? [y/N]:

詳細はこちら

AWS SAM パイプラインでの OIDC の使用の詳細については、「」を参照してくださいsam pipeline bootstrap