
# 网关身份策略授权参考
云服务在IAM预置了常用的权限，称为系统身份策略。如果IAM系统身份策略无法满足授权要求，管理员可以根据各服务支持的授权项，创建IAM自定义身份策略来进行精细的访问控制，IAM自定义身份策略是对系统身份策略的扩展和补充。
除IAM服务外，[Organizations](https://support.huaweicloud.com/productdesc-organizations/org_01_0011.html)服务中的[服务控制策略](https://support.huaweicloud.com/usermanual-organizations/org_03_0065.html)（Service Control Policy，以下简称SCP）也可以使用这些授权项元素设置访问控制策略。
SCP不直接进行授权，只划定权限边界。将SCP绑定到组织单元或者成员账号时，并没有直接对组织单元或成员账号授予操作权限，而是规定了成员账号或组织单元包含的成员账号的授权范围。IAM身份策略授予权限的有效性受SCP限制，只有在SCP允许范围内的权限才能生效。
IAM服务与Organizations服务在使用这些元素进行访问控制时，存在着一些区别，详情请参见：[IAM服务与Organizations服务权限访问控制的区别](https://support.huaweicloud.com/organizations_faq/org_06_0004.html)。
本章节介绍IAM服务身份策略授权场景中自定义身份策略和组织服务中SCP使用的元素，这些元素包含了操作（Action）、资源（Resource）和条件（Condition）。
- 如何使用这些元素编辑IAM自定义身份策略，请参考[创建自定义身份策略](https://support.huaweicloud.com/usermanual-iam5/iam_01_0917.html)。
- 如何使用这些元素编辑SCP自定义策略，请参考[创建SCP](https://support.huaweicloud.com/usermanual-organizations/org_03_0035.html)。
#### 操作（Action）
操作（Action）即为身份策略中支持的授权项。
- "访问级别"列描述如何对操作进行分类（List、Read和Write等）。此分类可帮助您了解在身份策略中相应操作对应的访问级别。
- "资源类型"列指每个操作是否支持资源级权限。
  - 资源类型支持通配符号\*表示所有。如果此列没有值（-），则必须在身份策略语句的Resource元素中指定所有资源类型（"\*"）。
  
  - 如果该列包含资源类型，则必须在具有该操作的语句中指定该资源的URN。
  
  - 资源类型列中必需资源在表中用星号（\*）标识，表示使用此操作必须指定该资源类型。
  
  
  关于AgentArts定义的资源类型的详细信息请参见[资源类型（Resource）]。
  
- "条件键"列包括了可以在身份策略语句的Condition元素中支持指定的键值。
  - 如果该授权项资源类型列存在值，则表示条件键仅对列举的资源类型生效。
  
  - 如果该授权项资源类型列没有值（-），则表示条件键对整个授权项生效。
  
  - 如果此列条件键没有值（-），表示此操作不支持指定条件键。
  
  
  关于AgentArts定义的条件键的详细信息请参见[条件（Condition）]。
  
- "别名"列包括了可以在身份策略中配置的策略授权项。通过这些授权项，可以控制支持策略授权的API访问。详细信息请参见[身份策略兼容性说明](https://support.huaweicloud.com/iam5_faq/iam_01_1103.html)。
您可以在身份策略语句的Action元素中指定以下AgentArts的相关操作。
表1AgentArts支持的授权项 
| 授权项                                       | 描述                      | 访问级别  | 资源类型（\*为必须） | 条件键                                                                                                                                                                                                                                                                                                                                          | 别名 |
|:---|:---|:---|:---|:---|:---|
| agentarts:gateway:createCoreGateway       | 授予权限以创建 AgentArts 网关。   | Write | gateway \*  | -                                                                                                                                                                                                                                                                                                                                            | -  |
| agentarts:gateway:createCoreGateway       | 授予权限以创建 AgentArts 网关。   | Write | -           | - [g:RequestTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)  - [g:TagKeys](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)   | -  |
| agentarts:gateway:listCoreGateways        | 授予权限以列出所有 AgentArts 网关。 | List  | -           | - [g:RequestTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)  - [g:TagKeys](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)   | -  |
| agentarts:gateway:showCoreGateway         | 授予权限以查看 AgentArts 网关详情。 | Read  | gateway \*  | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts:gateway:updateCoreGateway       | 授予权限以更新 AgentArts 网关配置。 | Write | gateway \*  | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts:gateway:updateCoreGateway       | 授予权限以更新 AgentArts 网关配置。 | Write | -           | - [g:RequestTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)  - [g:TagKeys](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)   | -  |
| agentarts:gateway:deleteCoreGateway       | 授予权限以删除 AgentArts 网关。   | Write | gateway \*  | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts:gateway:createCoreGatewayTarget | 授予权限以为指定网关创建目标服务。       | Write | gateway \*  | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts:gateway:listCoreGatewayTargets  | 授予权限以列出指定网关的所有目标服务。     | List  | gateway \*  | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts:gateway:showCoreGatewayTarget   | 授予权限以查看目标服务详情。          | Read  | gateway \*  | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts:gateway:updateCoreGatewayTarget | 授予权限以更新目标服务配置。          | Write | gateway \*  | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts:gateway:deleteCoreGatewayTarget | 授予权限以删除目标服务。            | Write | gateway \*  | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts:gateway:syncCoreGatewayTargets  | 授予权限以同步网关工具列表。          | Write | gateway \*  | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts::listResourcesByTag             | 授予权限以根据标签查询网关资源。        | List  | -           | [g:TagKeys](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                                | -  |
| agentarts::tagResource                    | 授予权限以批量添加网关标签。          | Write | gateway \*  | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts::tagResource                    | 授予权限以批量添加网关标签。          | Write | -           | - [g:RequestTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)  - [g:TagKeys](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)   | -  |
| agentarts::unTagResource                  | 授予权限以批量删除网关标签。          | Write | gateway \*  | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts::unTagResource                  | 授予权限以批量删除网关标签。          | Write | -           | - [g:RequestTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)  - [g:TagKeys](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)   | -  |
| agentarts::listTagsForResource            | 授予权限以查询网关标签列表。          | List  | gateway \*  | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts::listTags                       | 授予权限以查询账号下所有网关标签列表。     | List  | -           | -                                                                                                                                                                                                                                                                                                                                            | -  |
| agentarts:gateway:debugCoreGateway        | 授予权限以调测网关。              | Write | gateway \*  | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
   
AgentArts的API通常对应着一个或多个授权项。[表2]展示了API与授权项的关系，以及该API需要依赖的授权项。
 表2API与授权项的关系 
| API                                                                                                                                     | 对应的授权项                                    | 依赖的授权项                                                                                                                                                                                                                                                                                                                                                                                              |
|:---|:---|:---|
| [POST /v1/core/gateways](https://support.huaweicloud.com/api-agentarts/CreateCoreGateway.html)                                          | agentarts:gateway:createCoreGateway       | - iam:agencies:pass  - vpc:nativePorts:create  - vpc:routeTables:update  - eip:publicIps:associateInstance   |
| [GET /v1/core/gateways](https://support.huaweicloud.com/api-agentarts/ListCoreGateways.html)                                            | agentarts:gateway:listCoreGateways        | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [GET /v1/core/gateways/{gateway_id}](https://support.huaweicloud.com/api-agentarts/ShowCoreGateway.html)                                | agentarts:gateway:showCoreGateway         | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [PUT /v1/core/gateways/{gateway_id}](https://support.huaweicloud.com/api-agentarts/UpdateCoreGateway.html)                              | agentarts:gateway:updateCoreGateway       | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [DELETE /v1/core/gateways/{gateway_id}](https://support.huaweicloud.com/api-agentarts/DeleteCoreGateway.html)                           | agentarts:gateway:deleteCoreGateway       | - vpc:routeTables:update  - vpc:nativePorts:delete  - eip:publicIps:disassociateInstance                                                                                   |
| [POST /v1/core/gateways/{gateway_id}/targets](https://support.huaweicloud.com/api-agentarts/CreateCoreGatewayTarget.html)               | agentarts:gateway:createCoreGatewayTarget | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [GET /v1/core/gateways/{gateway_id}/targets](https://support.huaweicloud.com/api-agentarts/ListCoreGatewayTargets.html)                 | agentarts:gateway:listCoreGatewayTargets  | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [GET /v1/core/gateways/{gateway_id}/targets/{target_id}](https://support.huaweicloud.com/api-agentarts/ShowCoreGatewayTarget.html)      | agentarts:gateway:showCoreGatewayTarget   | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [PUT /v1/core/gateways/{gateway_id}/targets/{target_id}](https://support.huaweicloud.com/api-agentarts/UpdateCoreGatewayTarget.html)    | agentarts:gateway:updateCoreGatewayTarget | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [DELETE /v1/core/gateways/{gateway_id}/targets/{target_id}](https://support.huaweicloud.com/api-agentarts/DeleteCoreGatewayTarget.html) | agentarts:gateway:deleteCoreGatewayTarget | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [PUT /v1/core/gateways/{gateway_id}/synchronize-targets](https://support.huaweicloud.com/api-agentarts/SyncCoreGatewayTargets.html)     | agentarts:gateway:syncCoreGatewayTargets  | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [POST /v1/gateways/resource-instances/filter](https://support.huaweicloud.com/api-agentarts/ListCoreGatewaysByTags.html)                | agentarts::listResourcesByTag             | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [POST /v1/gateways/resource-instances/count](https://support.huaweicloud.com/api-agentarts/ShowCoreGatewayNumsByTags.html)              | agentarts::listResourcesByTag             | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [POST /v1/gateways/{gateway_id}/tags/create](https://support.huaweicloud.com/api-agentarts/BatchCreateCoreGatewayTags.html)             | agentarts::tagResource                    | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [POST /v1/gateways/{gateway_id}/tags/delete](https://support.huaweicloud.com/api-agentarts/BatchDeleteCoreGatewayTags.html)             | agentarts::unTagResource                  | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [GET /v1/gateways/{gateway_id}/tags](https://support.huaweicloud.com/api-agentarts/ListCoreGatewayTags.html)                            | agentarts::listTagsForResource            | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [GET /v1/gateways/tags](https://support.huaweicloud.com/api-agentarts/ListAllCoreGatewayTags.html)                                      | agentarts::listTags                       | -                                                                                                                                                                                                                                                                                                                                                                                                   |
   
 #### 资源类型（Resource）
资源类型（Resource）用于定义身份策略生效的资源范围。如[表3]中某项操作已指定了对应的资源类型，则在包含该操作的身份策略语句中选择填写对应资源的URN时，身份策略仅对该指定资源生效；未填写对应资源的URN时，身份策略将对指定资源类型下所有资源生效；如未指定资源类型，Resource默认取值为"\*"，身份策略将作用于所有资源。此外，您也可在身份策略中设置条件，进一步精细化限定资源类型。
AgentArts定义了以下可以在自定义身份策略的Resource元素中使用的资源类型。
 表3AgentArts支持的资源类型 
| 资源类型    | URN                                                           |
|:---|:---|
| gateway | agentArts:\<region-id\>:\<account-id\>:gateway:\<gateway_id\> |
| gateway | agentArts:\<region\>:\<account-id\>:gateway:\<gateway_id\>    |
| gateway | agentarts:\<region-id\>:\<account-id\>:gateway:\<gateway_id\> |
| gateway | agentarts:\<region\>:\<account-id\>:gateway:\<gateway_id\>    |
   
 #### 条件（Condition）
AgentArts服务不支持在身份策略中的条件键中配置服务级的条件键。AgentArts可以使用适用于所有服务的全局条件键，请参考[全局条件键](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)。
