本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
在Amazon SAM管道中使用 OIDC 身份验证
Amazon Serverless Application Model(Amazon SAM) 支持 Bitbucket、Ac GitHub tions 以及 GitLab 持续集成和持续交付 (CI/CD) 平台的 OpenID Connect (OIDC) 用户身份验证。有了这种支持,您就可以使用这些平台上的授权 CI/CD 用户帐户来管理您的无服务器应用程序管道。否则,您将需要创建和管理多个Amazon Identity and Access Management (IAM) 用户来控制对Amazon SAM管道的访问权限。
使用Amazon SAM管道设置 OIDC
在sam pipeline bootstrap配置过程中,执行以下操作以使用您的Amazon SAM管道设置 OIDC。
-
当提示选择身份提供者时,选择 OIDC。
-
接下来,选择支持的 OIDC 提供商。
-
输入 OIDC 提供商 URL,开头为
https://。注意
Amazon SAM生成
AWS::IAM::OIDCProvider资源类型时引用此 URL。 -
接下来,按照提示输入访问所选平台所需的 CI/CD 平台信息。这些详细信息因平台而异,可能包括:
-
OUC 客户端 ID。
-
代码存储库名称或通用唯一标识符 (UUID)。
-
与存储库关联的通用或组织名称。
-
GitHub 代码存储库所属的组织。
-
GitHub 存储库名称。
-
进行部署的分支。
-
-
Amazon SAM显示输入的 OIDC 配置的摘要。输入设置的编号进行编辑,或按下Enter继续。
-
当提示确认创建支持输入的 OIDC 连接所需的资源时,Y按下继续。
Amazon SAM使用提供的配置生成AWS::IAM::OIDCProviderAmazon CloudFormation资源,该资源担任管道执行角色。要了解有关此Amazon CloudFormation资源类型的更多信息,请参阅Amazon CloudFormation用户指南中的 AWS:: IAM:: OIDCProvid er。
注意
如果您的中已经存在身份提供商 (IdP) 资源Amazon Web Services 账户,请Amazon SAM引用该资源,而不是创建新资源。
示例
以下是使用Amazon 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]:
了解更多信息
有关在Amazon SAM管道中使用 OIDC 的更多信息,请参阅sam 管道引导。