

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# AWS CodeStar 通知的身份和访问权限管理 AWS CodeConnections
<a name="security-iam"></a>

AWS Identity and Access Management (IAM) AWS 服务 可帮助管理员安全地控制对 AWS 资源的访问权限。IAM 管理员控制谁可以*进行身份验证*（登录）和*授权（有权*限）使用 AWS CodeStar 通知和 AWS CodeConnections 资源。您可以使用 IAM AWS 服务 ，无需支付额外费用。

**注意**  
可以对在新服务前缀下创建`codeconnections`的资源执行操作。在新服务前缀下创建资源将在资源 ARN `codeconnections` 中使用。`codestar-connections`服务前缀的操作和资源仍然可用。在 IAM 策略中指定资源时，服务前缀需要与资源的服务前缀相匹配。

**Topics**
+ [受众](#security_iam_audience)
+ [使用身份进行身份验证](#security_iam_authentication)
+ [使用策略管理访问](#security_iam_access-manage)
+ [开发工具控制台中的特征如何与 IAM 配合使用](security_iam_service-with-iam.md)
+ [AWS CodeConnections 权限参考](#permissions-reference-connections)
+ [基于身份的策略示例](security_iam_id-based-policy-examples.md)
+ [使用标签控制对 AWS CodeConnections 资源的访问权限](connections-tag-based-access-control.md)
+ [使用控制台中的通知和连接](#security_iam_id-based-policy-examples-console)
+ [允许用户查看他们自己的权限](#security_iam_id-based-policy-examples-view-own-permissions)
+ [故障排除 AWS CodeStar 通知、 AWS CodeConnections 身份和访问权限](security_iam_troubleshoot.md)
+ [为 AWS CodeStar 通知使用服务相关角色](using-service-linked-roles.md)
+ [将服务相关角色用于 AWS CodeConnections](service-linked-role-connections.md)
+ [AWS 的托管策略 AWS CodeConnections](security-iam-awsmanpol.md)

## 受众
<a name="security_iam_audience"></a>

您的使用方式 AWS Identity and Access Management (IAM) 因您的角色而异：
+ **服务用户**：如果您无法访问功能，请从管理员处请求权限（请参阅[故障排除 AWS CodeStar 通知、 AWS CodeConnections 身份和访问权限](security_iam_troubleshoot.md)）
+ **服务管理员**：确定用户访问权限并提交权限请求（请参阅[开发工具控制台中的特征如何与 IAM 配合使用](security_iam_service-with-iam.md)）
+ **IAM 管理员**：编写用于管理访问权限的策略（请参阅[基于身份的策略示例](security_iam_id-based-policy-examples.md)）

## 使用身份进行身份验证
<a name="security_iam_authentication"></a>

身份验证是您 AWS 使用身份凭证登录的方式。您必须以 IAM 用户身份进行身份验证 AWS 账户根用户，或者通过担任 IAM 角色进行身份验证。

您可以使用来自身份源的证书 AWS IAM Identity Center （例如（IAM Identity Center）、单点登录身份验证或 Google/Facebook 证书，以联合身份登录。有关登录的更多信息，请参阅《AWS 登录 用户指南》**中的[如何登录您的 AWS 账户](https://docs.aws.amazon.com/signin/latest/userguide/how-to-sign-in.html)。

对于编程访问， AWS 提供 SDK 和 CLI 来对请求进行加密签名。有关更多信息，请参阅*《IAM 用户指南》*中的[适用于 API 请求的AWS 签名版本 4](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv.html)。

### AWS 账户根用户
<a name="security_iam_authentication-rootuser"></a>

 创建时 AWS 账户，首先会有一个名为 AWS 账户 *root 用户的*登录身份，该身份可以完全访问所有资源 AWS 服务 和资源。我们强烈建议不要使用根用户进行日常任务。有关要求根用户凭证的任务，请参阅*《IAM 用户指南》*中的[需要根用户凭证的任务](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-user.html#root-user-tasks)。

### IAM 用户和群组
<a name="security_iam_authentication-iamuser"></a>

*[IAM 用户](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html)*是对某个人员或应用程序具有特定权限的一个身份。建议使用临时凭证，而非具有长期凭证的 IAM 用户。有关更多信息，请参阅 *IAM 用户指南*[中的要求人类用户使用身份提供商的联合身份验证才能 AWS 使用临时证书进行访问](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#bp-users-federation-idp)。

[https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups.html](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups.html)指定一组 IAM 用户，便于更轻松地对大量用户进行权限管理。有关更多信息，请参阅*《IAM 用户指南》*中的 [IAM 用户使用案例](https://docs.aws.amazon.com/IAM/latest/UserGuide/gs-identities-iam-users.html)。

### IAM 角色
<a name="security_iam_authentication-iamrole"></a>

*[IAM 角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)*是具有特定权限的身份，可提供临时凭证。您可以通过[从用户切换到 IAM 角色（控制台）](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-console.html)或调用 AWS CLI 或 AWS API 操作来代入角色。有关更多信息，请参阅《IAM 用户指南》**中的[担任角色的方法](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_manage-assume.html)。

IAM 角色对于联合用户访问、临时 IAM 用户权限、跨账户访问、跨服务访问以及在 Amazon EC2 上运行的应用程序非常有用。有关更多信息，请参阅《IAM 用户指南》**中的 [IAM 中的跨账户资源访问](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies-cross-account-resource-access.html)。

## 使用策略管理访问
<a name="security_iam_access-manage"></a>

您可以 AWS 通过创建策略并将其附加到 AWS 身份或资源来控制中的访问权限。策略定义了与身份或资源关联时的权限。 AWS 在委托人提出请求时评估这些政策。大多数策略都以 JSON 文档的 AWS 形式存储在中。有关 JSON 策略文档的更多信息，请参阅*《IAM 用户指南》*中的 [JSON 策略概述](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#access_policies-json)。

管理员使用策略，通过定义哪个**主体**可以在什么**条件**下对哪些**资源**执行哪些**操作**来指定谁有权访问什么。

默认情况下，用户和角色没有权限。IAM 管理员创建 IAM 策略并将其添加到角色中，然后用户可以担任这些角色。IAM 策略定义权限，与执行操作所用的方法无关。

### 基于身份的策略
<a name="security_iam_access-manage-id-based-policies"></a>

基于身份的策略是您附加到身份（用户、组或角色）的 JSON 权限策略文档。这些策略控制身份可以执行什么操作、对哪些资源执行以及在什么条件下执行。要了解如何创建基于身份的策略，请参阅《IAM 用户指南》**中的[使用客户管理型策略定义自定义 IAM 权限](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html)。

基于身份的策略可以是*内联策略*（直接嵌入到单个身份中）或*托管策略*（附加到多个身份的独立策略）。要了解如何在托管策略和内联策略之间进行选择，请参阅*《IAM 用户指南》*中的[在托管策略与内联策略之间进行选择](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies-choosing-managed-or-inline.html)。

## AWS CodeConnections 权限参考
<a name="permissions-reference-connections"></a>

下表列出了每个 AWS CodeConnections API 操作、您可以为其授予权限的相应操作以及用于授予权限的资源 ARN 的格式。根据该 API 允许的操作范围将 AWS CodeConnections APIs 它们分成表格。在编写可附加到 IAM 身份的权限策略（基于身份的策略）时，可参考此表。

在创建权限策略时，可以在策略的 `Action` 字段中指定操作。在策略的 `Resource` 字段中以 ARN 的形式指定资源值，可以使用或不使用通配符 (\*)。

要在连接策略中表达条件，可以使用此处描述的和 [条件键](security_iam_service-with-iam.md#security_iam_service-with-iam-id-based-policies-conditionkeys) 中列出的条件键。您也可以使用 AWS-wide 条件键。有关 AWS范围密钥的完整列表，请参阅 *IAM 用户指南*中的[可用密钥](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html#AvailableKeys)。

要指定操作，请在 API 操作名称之前使用 `codeconnections` 前缀 (例如，`codeconnections:ListConnections` 或 `codeconnections:CreateConnection`)。

**使用通配符**

要指定多个操作或资源，可以在 ARN 中使用通配符 (\*)。例如，`codeconnections:*`指定所有 AWS CodeConnections 动作并`codeconnections:Get*`指定以单词开头的所有 AWS CodeConnections 动作`Get`。以下示例授予对以 `MyConnection` 名称开头的所有资源的访问权限。

```
arn:aws:codeconnections:us-west-2:{{account-ID}}:connection/*
```

只能对下表中列出的{{connection}}资源使用通配符。不能在{{region}}或{{account-id}}资源中使用通配符。有关通配符的更多信息，请参阅 *IAM 用户指南*中的 [IAM 标识符](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html)。

**Topics**
+ [用于管理连接的权限](#permissions-reference-connections-managing)
+ [用于管理主机的权限](#permissions-reference-connections-hosts)
+ [用于完成连接的权限](#permissions-reference-connections-handshake)
+ [设置主机的权限](#connections-permissions-actions-host-registration)
+ [将连接传递到服务](#permissions-reference-connections-passconnection)
+ [使用连接](#permissions-reference-connections-use)
+ [对于 `ProviderAction` 支持的访问类型](#permissions-reference-connections-access)
+ [标记连接资源支持的权限](#permissions-reference-connections-tagging)
+ [将连接传递到存储库链接](#permissions-reference-connections-passrepository)
+ [存储库链接支持的条件键](#permissions-reference-connections-branch)
+ [支持的连接共享权限](#permissions-reference-connections-sharing)

### 用于管理连接的权限
<a name="permissions-reference-connections-managing"></a>

被指定使用或 SDK 查看、创建 AWS CLI 或删除连接的角色或用户的权限应限制为以下内容。

**注意**  
您无法在仅具有以下权限的情况时，在控制台中完成或使用连接。您需要添加 [用于完成连接的权限](#permissions-reference-connections-handshake) 中的权限。

```
codeconnections:CreateConnection
codeconnections:DeleteConnection
codeconnections:GetConnection
codeconnections:ListConnections
```

使用滚动条查看表的其余部分。


**AWS CodeConnections 管理连接所需的权限**  

| AWS CodeConnections 行动 | 所需的权限  | 资源 | 
| --- | --- | --- | 
| CreateConnection | `codeconnections:CreateConnection`<br />使用 CLI 或控制台创建连接所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| DeleteConnection | `codeconnections:DeleteConnection`<br />使用 CLI 或控制台删除连接所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| GetConnection | `codeconnections:GetConnection`<br />使用 CLI 或控制台查看连接详细信息所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| ListConnections | `codeconnections:ListConnections`<br />使用 CLI 或控制台列出账户中的所有连接所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 

这些操作支持以下条件键：


| Action | 条件键 | 
| --- | --- | 
| `codeconnections:CreateConnection` | `codeconnections:ProviderType` | 
|  codeconnections:DeleteConnection | 不适用 | 
| codeconnections:GetConnection | 不适用 | 
| codeconnections:ListConnections | codeconnections:ProviderTypeFilter | 

### 用于管理主机的权限
<a name="permissions-reference-connections-hosts"></a>

被指定使用或 SDK 查看、创建 AWS CLI 或删除主机的角色或用户的权限应限制为以下内容。

**注意**  
您无法在仅具有以下权限的情况时，在主机中完成或使用连接。您需要添加 [设置主机的权限](#connections-permissions-actions-host-registration) 中的权限。

```
codeconnections:CreateHost
codeconnections:DeleteHost
codeconnections:GetHost
codeconnections:ListHosts
```

使用滚动条查看表的其余部分。


**AWS CodeConnections 管理主机所需的权限**  

| AWS CodeConnections 行动 | 所需的权限  | 资源 | 
| --- | --- | --- | 
| CreateHost | `codeconnections:CreateHost`<br />使用 CLI 或控制台创建主机所必需。 | arn: aws: codeconnections:: host/ {{region}} {{account-id}} {{host-id}} | 
| DeleteHost | `codeconnections:DeleteHost`<br />使用 CLI 或控制台删除主机所必需。 | 代码连接::: {{region}} host/ {{account-id}} {{host-id}} | 
| GetHost | `codeconnections:GetHost`<br />使用 CLI 或控制台查看主机详细信息所必需。 | arn: aws: codeconnections:: host/ {{region}} {{account-id}} {{host-id}} | 
| ListHosts | `codeconnections:ListHosts`<br />使用 CLI 或控制台列出账户中的所有主机所必需。 | arn: aws: codeconnections:: host/ {{region}} {{account-id}} {{host-id}} | 

这些操作支持以下条件键：


| Action | 条件键 | 
| --- | --- | 
| `codeconnections:CreateHost` | `codeconnections:ProviderType`<br />`codeconnections:VpcId` | 
|  codeconnections:DeleteHost | 不适用 | 
| codeconnections:GetHost | 不适用 | 
| codeconnections:ListHosts | codeconnections:ProviderTypeFilter | 

有关使用**VpcId**条件密钥的策略示例，请参阅[示例：使用**VpcId**上下文密钥限制主机 VPC 权限](security_iam_id-based-policy-examples-connections.md#security_iam_id-based-policy-examples-connections-vpc)。

### 用于完成连接的权限
<a name="permissions-reference-connections-handshake"></a>

指定用于在控制台中管理连接的角色或用户，应具有在控制台中完成连接和创建安装所需的权限，这包括授权与提供程序握手和为要使用的连接创建安装。除了上述权限之外，还可以使用以下权限。

控制台在执行基于浏览器的握手时使用以下 IAM 操作。`ListInstallationTargets`、`GetInstallationUrl`、`StartOAuthHandshake`、`UpdateConnectionInstallation` 和 `GetIndividualAccessToken` 是 IAM 策略权限。它们不是 API 操作。

```
codeconnections:GetIndividualAccessToken
codeconnections:GetInstallationUrl
codeconnections:ListInstallationTargets
codeconnections:StartOAuthHandshake
codeconnections:UpdateConnectionInstallation
```

基于这一点，在控制台中使用、创建、更新或删除连接需要以下权限。

```
codeconnections:CreateConnection
codeconnections:DeleteConnection
codeconnections:GetConnection
codeconnections:ListConnections
codeconnections:UseConnection
codeconnections:ListInstallationTargets
codeconnections:GetInstallationUrl
codeconnections:StartOAuthHandshake
codeconnections:UpdateConnectionInstallation
codeconnections:GetIndividualAccessToken
```

使用滚动条查看表的其余部分。


**AWS CodeConnections 完成连接所需的权限**  

| AWS CodeConnections 行动 | 所需的权限  | 资源 | 
| --- | --- | --- | 
| `GetIndividualAccessToken` | `codeconnections:GetIndividualAccessToken`<br />使用控制台完成连接所必需。这只是一种 IAM 策略权限，不是 API 操作。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| `GetInstallationUrl` | `codeconnections:GetInstallationUrl`<br />使用控制台完成连接所必需。这只是一种 IAM 策略权限，不是 API 操作。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| `ListInstallationTargets` | `codeconnections:ListInstallationTargets`<br />使用控制台完成连接所必需。这只是一种 IAM 策略权限，不是 API 操作。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| `StartOAuthHandshake` | `codeconnections:StartOAuthHandshake`<br />使用控制台完成连接所必需。这只是一种 IAM 策略权限，不是 API 操作。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| `UpdateConnectionInstallation` | `codeconnections:UpdateConnectionInstallation`<br />使用控制台完成连接所必需。这只是一种 IAM 策略权限，不是 API 操作。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 

这些操作支持以下条件键。


| Action | 条件键 | 
| --- | --- | 
| codeconnections:GetIndividualAccessToken | codeconnections:ProviderType | 
|  codeconnections:GetInstallationUrl | codeconnections:ProviderType | 
| `codeconnections:ListInstallationTargets` | 不适用 | 
| codeconnections:StartOAuthHandshake | codeconnections:ProviderType | 
| codeconnections:UpdateConnectionInstallation | codeconnections:InstallationId | 

### 设置主机的权限
<a name="connections-permissions-actions-host-registration"></a>

指定在控制台中管理连接的角色或用户应具有在控制台中设置主机所需的权限，包括向提供程序授权握手和安装主机应用程序。除了上述主机权限之外，还可以使用以下权限。

控制台在执行基于浏览器的主机注册时使用以下 IAM 操作。`RegisterAppCode` 和 `StartAppRegistrationHandshake` 是 IAM 策略权限。它们不是 API 操作。

```
codeconnections:RegisterAppCode
codeconnections:StartAppRegistrationHandshake
```

基于这一点，在控制台中使用、创建、更新或删除需要主机的连接需要以下权限（例如已安装的提供程序类型）。

```
codeconnections:CreateConnection
codeconnections:DeleteConnection
codeconnections:GetConnection
codeconnections:ListConnections
codeconnections:UseConnection
codeconnections:ListInstallationTargets
codeconnections:GetInstallationUrl
codeconnections:StartOAuthHandshake
codeconnections:UpdateConnectionInstallation
codeconnections:GetIndividualAccessToken
codeconnections:RegisterAppCode
codeconnections:StartAppRegistrationHandshake
```

使用滚动条查看表的其余部分。


**AWS CodeConnections 完成主机设置所需的权限**  

| 连接操作 | 所需的权限  | 资源 | 
| --- | --- | --- | 
| `RegisterAppCode` | `codeconnections:RegisterAppCode`<br />使用控制台来完成主机设置所必需。这只是一种 IAM 策略权限，不是 API 操作。 | arn: aws: codeconnections:: host/ {{region}} {{account-id}} {{host-id}} | 
| `StartAppRegistrationHandshake` | `codeconnections:StartAppRegistrationHandshake`<br />使用控制台来完成主机设置所必需。这只是一种 IAM 策略权限，不是 API 操作。 | arn: aws: codeconnections:: host/ {{region}} {{account-id}} {{host-id}} | 

这些操作支持以下条件键。

### 将连接传递到服务
<a name="permissions-reference-connections-passconnection"></a>

将连接传递到服务时（例如，在管道定义中提供连接 ARN 以创建或更新管道时），用户必须具有 `codeconnections:PassConnection` 权限。

使用滚动条查看表的其余部分。


**AWS CodeConnections 传递连接所需的权限**  

| AWS CodeConnections 行动 | 所需的权限  | 资源 | 
| --- | --- | --- | 
| `PassConnection` | `codeconnections:PassConnection`<br />将连接传递到服务所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 

此操作还支持以下条件键：
+ `codeconnections:PassedToService`


**条件键的受支持值**  

| Key | 有效操作提供方 | 
| --- | --- | 
| `codeconnections:PassedToService` |  [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/dtconsole/latest/userguide/security-iam.html)  | 

### 使用连接
<a name="permissions-reference-connections-use"></a>

当诸如此类的服务 CodePipeline 使用连接时，该服务角色必须具有对给定连接的`codeconnections:UseConnection`权限。

要在控制台中管理连接，用户策略必须具有 `codeconnections:UseConnection` 权限。

使用滚动条查看表的其余部分。


**AWS CodeConnections 使用连接所需的操作**  

| AWS CodeConnections 行动 | 所需的权限  | 资源 | 
| --- | --- | --- | 
| `UseConnection` | `codeconnections:UseConnection`<br />使用连接所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 

此操作还支持以下条件键：
+ `codeconnections:BranchName`
+ `codeconnections:FullRepositoryId`
+ `codeconnections:OwnerId`
+ `codeconnections:ProviderAction`
+ `codeconnections:ProviderPermissionsRequired`
+ `codeconnections:RepositoryName`


**条件键的受支持值**  

| Key | 有效操作提供方 | 
| --- | --- | 
| `codeconnections:FullRepositoryId` | 存储库的用户名和存储库名称，例如 `my-owner/my-repository`。仅当连接用于访问特定存储库时才支持。 | 
| `codeconnections:ProviderPermissionsRequired` | read\_only 或 read\_write | 
| `codeconnections:ProviderAction` | `GetBranch`, `ListRepositories`, `ListOwners`, `ListBranches`, `StartUploadArchiveToS3`, `GitPush`, `GitPull`, `GetUploadArchiveToS3Status`, `CreatePullRequestDiffComment`, `GetPullRequest`, `ListBranchCommits`, `ListCommitFiles`, `ListPullRequestComments`, `ListPullRequestCommits`.<br />有关信息，请参阅下一部分。 | 

某个功能所需的条件键可能会随着时间的推移而更改。建议使用 `codeconnections:UseConnection` 来控制对连接的访问，除非您的访问控制需求不同的权限。

### 对于 `ProviderAction` 支持的访问类型
<a name="permissions-reference-connections-access"></a>

当 AWS 服务使用连接时，会导致向您的源代码提供商发出 API 调用。例如，服务可能会通过调用 `https://api.bitbucket.org/2.0/repositories/{{username}}` API 来列出 Bitbucket 连接的存储库。

`ProviderAction`条件键允许您限制在提供商 APIs 上可以调用哪个。由于 API 路径可能是动态生成的，并且路径因提供方而异，因此 `ProviderAction` 值映射到抽象操作名称而不是 API 的 URL。这允许您编写具有相同效果的策略，无论连接的提供程序类型如何。

以下是授予每个受支持的 `ProviderAction` 值的访问类型。以下是 IAM 策略权限。它们不是 API 操作。

使用滚动条查看表的其余部分。


**AWS CodeConnections 支持的访问类型 `ProviderAction`**  

| AWS CodeConnections 许可 | 所需的权限  | 资源 | 
| --- | --- | --- | 
| `GetBranch` | ` codeconnections:GetBranch`<br />访问有关分支的信息所必需，例如该分支的最新提交。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| `ListRepositories` | ` codeconnections:ListRepositories`<br />访问属于所有者的公有存储库和私有存储库列表（包括有关这些存储库的详细信息）时所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| `ListOwners` | `codeconnections:ListOwners`<br />访问连接有权访问的拥有者列表所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| `ListBranches` | ` codeconnections:ListBranches`<br />访问给定存储库上存在的分支列表所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| `StartUploadArchiveToS3` | ` codeconnections:StartUploadArchiveToS3`<br />读取源代码并将其上传到 Amazon S3 所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| `GitPush` | ` codeconnections:GitPush`<br />使用 Git 写入存储库所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| `GitPull` | ` codeconnections:GitPull`<br />使用 Git 从存储库读取所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| GetUploadArchiveToS3Status | ` codeconnections:GetUploadArchiveToS3Status`<br />访问 `StartUploadArchiveToS3` 启动的上传的状态所必需，包括任何错误消息。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| CreatePullRequestDiffComment | ` codeconnections:CreatePullRequestDiffComment`<br />访问拉取请求的注释所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| GetPullRequest | ` codeconnections:GetPullRequest`<br />查看存储库的拉取请求所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| `ListBranchCommits` | ` codeconnections:ListBranchCommits`<br />查看存储库分支的提交的列表所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| `ListCommitFiles` | ` codeconnections:ListCommitFiles`<br />查看要提交文件的列表所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| `ListPullRequestComments` | ` codeconnections:ListPullRequestComments`<br />查看拉取请求的注释的列表所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 
| `ListPullRequestCommits` | ` codeconnections:ListPullRequestCommits`<br />查看拉取请求的提交的列表所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 

### 标记连接资源支持的权限
<a name="permissions-reference-connections-tagging"></a>

标记连接资源时使用以下 IAM 操作。

```
codeconnections:ListTagsForResource
codeconnections:TagResource
codeconnections:UntagResource
```

使用滚动条查看表的其余部分。


**AWS CodeConnections 标记连接资源所需的操作**  

| AWS CodeConnections 行动 | 所需的权限  | 资源 | 
| --- | --- | --- | 
| `ListTagsForResource` | `codeconnections:ListTagsForResource`<br />查看与连接资源关联的标签列表所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}},<br />arn: aws: codeconnections:: host/ {{region}} {{account-id}} {{host-id}} | 
| `TagResource` | `codeconnections:TagResource`<br />标记连接资源所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}},<br />arn: aws: codeconnections:: host/ {{region}} {{account-id}} {{host-id}} | 
| `UntagResource` | `codeconnections:UntagResource`<br />从连接资源移除标签时所必需。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}},<br />arn: aws: codeconnections:: host/ {{region}} {{account-id}} {{host-id}} | 

### 将连接传递到存储库链接
<a name="permissions-reference-connections-passrepository"></a>

在同步配置中提供存储库链接时，用户必须拥有存储库链接 ARN/resource 的 `codeconnections:PassRepository` 权限。

使用滚动条查看表的其余部分。


**AWS CodeConnections 传递连接所需的权限**  

| AWS CodeConnections 行动 | 所需的权限  | 资源 | 
| --- | --- | --- | 
| `PassRepository` | `codeconnections:PassRepository`<br />需要将存储库链接传递到同步配置。 | arn: aws: codeconnections:: repository-lin {{region}} {{account-id}} {{repository-link-id}} | 

此操作还支持以下条件键：
+ `codeconnections:PassedToService`


**条件键的受支持值**  

| Key | 有效操作提供方 | 
| --- | --- | 
| `codeconnections:PassedToService` |  [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/dtconsole/latest/userguide/security-iam.html)  | 

### 存储库链接支持的条件键
<a name="permissions-reference-connections-branch"></a>

以下条件键支持对存储库链接和同步配置资源的操作：
+ `codeconnections:Branch`

  按请求中传递的分支名称来筛选访问权限。


**条件键支持的操作**  

| Key | 有效值 | 
| --- | --- | 
| `codeconnections:Branch` | 此条件键支持以下操作：[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/dtconsole/latest/userguide/security-iam.html) | 

### 支持的连接共享权限
<a name="permissions-reference-connections-sharing"></a>

共享连接时使用以下 IAM 操作。

```
codeconnections:GetResourcePolicy
```

使用滚动条查看表的其余部分。


**AWS CodeConnections 共享连接所需的操作**  

| AWS CodeConnections 行动 | 所需的权限  | 资源 | 
| --- | --- | --- | 
| `GetResourcePolicy` | `codeconnections:GetResourcePolicy`<br />访问有关资源策略的信息所必需的。 | arn: aws: 代码连接::: 连接/ {{region}} {{account-id}} {{connection-id}} | 

有关连接共享的更多信息，请参阅[与共享连接 AWS 账户](connections-share.md)。

## 使用控制台中的通知和连接
<a name="security_iam_id-based-policy-examples-console"></a>

通知体验内置于 CodeBuild、 CodeCommit CodeDeploy、和 CodePipeline控制台中，以及开发者工具控制台的 **“设置”** 导航栏本身。要访问控制台中的通知，您必须为这些服务应用其中一项托管策略，或者必须具有一组最低权限。这些权限必须允许您列出和查看有关您 AWS 账户中的 AWS CodeStar 通知和 AWS CodeConnections 资源的详细信息。如果您创建的基于身份的策略比所需的最低权限更严格，则无法为具有该策略的实体（IAM 用户或角色）正常运行控制台。有关授予 AWS CodeBuild、 AWS CodeCommit AWS CodeDeploy AWS CodePipeline、和访问权限（包括对这些控制台的访问权限）的更多信息，请参阅以下主题：
+ CodeBuild: [将基于身份的策略用于 CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/security_iam_id-based-policy-examples.html#managed-policies)
+ CodeCommit: [将基于身份的策略用于 CodeCommit](https://docs.aws.amazon.com/codecommit/latest/userguide/auth-and-access-control-iam-identity-based-access-control.html)
+ AWS CodeDeploy: [身份和访问管理 AWS CodeDeploy](https://docs.aws.amazon.com/codedeploy/latest/userguide/security-iam.html)
+ CodePipeline: [使用 IAM 策略进行访问控制](https://docs.aws.amazon.com/codepipeline/latest/userguide/access-control.html)

AWS CodeStar 通知没有任何 AWS 托管策略。为了提供对通知功能的访问权限，您必须为前面列出的其中一项服务应用某种托管策略，或者您必须创建具有要授予用户或实体的权限级别的策略，然后将这些策略附加到需要这些权限的用户、组或角色。有关更多信息和示例，请参阅以下：
+ [示例：用于管理通知的管理员级别策略 AWS CodeStar](security_iam_id-based-policy-examples-notifications.md#security_iam_id-based-policy-examples-notifications-full-access)
+ [示例：用于使用通知的贡献者级别策略 AWS CodeStar](security_iam_id-based-policy-examples-notifications.md#security_iam_id-based-policy-examples-notifications-contributor)
+ [示例：使用 AWS CodeStar 通知的 read-only-level策略](security_iam_id-based-policy-examples-notifications.md#security_iam_id-based-policy-examples-notifications-read-only).



AWS CodeConnections 没有任何 AWS 托管策略。您可以使用权限和访问权限组合，例如，[用于完成连接的权限](#permissions-reference-connections-handshake)中详细叙述的权限。

有关更多信息，请参阅下列内容：
+ [示例：管理员级别的管理策略 AWS CodeConnections](security_iam_id-based-policy-examples-connections.md#security_iam_id-based-policy-examples-connections-fullaccess)
+ [示例：用于使用的贡献者级别的策略 AWS CodeConnections](security_iam_id-based-policy-examples-connections.md#security_iam_id-based-policy-examples-connections-contributor)
+ [示例：使用 read-only-level策略 AWS CodeConnections](security_iam_id-based-policy-examples-connections.md#security_iam_id-based-policy-examples-connections-readonly)

您无需为仅调用 AWS CLI 或 AWS API 的用户授予控制台权限。相反，只允许访问与您尝试执行的 API 操作相匹配的操作。

## 允许用户查看他们自己的权限
<a name="security_iam_id-based-policy-examples-view-own-permissions"></a>

该示例说明了您如何创建策略，以允许 IAM 用户查看附加到其用户身份的内联和托管式策略。此策略包括在控制台上或使用 AWS CLI 或 AWS API 以编程方式完成此操作的权限。

```
{
    "Version": "2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "ViewOwnUserInfo",
            "Effect": "Allow",
            "Action": [
                "iam:GetUserPolicy",
                "iam:ListGroupsForUser",
                "iam:ListAttachedUserPolicies",
                "iam:ListUserPolicies",
                "iam:GetUser"
            ],
            "Resource": ["arn:aws:iam::*:user/${aws:username}"]
        },
        {
            "Sid": "NavigateInConsole",
            "Effect": "Allow",
            "Action": [
                "iam:GetGroupPolicy",
                "iam:GetPolicyVersion",
                "iam:GetPolicy",
                "iam:ListAttachedGroupPolicies",
                "iam:ListGroupPolicies",
                "iam:ListPolicyVersions",
                "iam:ListPolicies",
                "iam:ListUsers"
            ],
            "Resource": "*"
        }
    ]
}
```