
# 沙箱工具身份策略授权参考
云服务在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:codeInterpreter:createCoreCodeInterpreter | 授予权限以创建代码解释器。    | Write   | codeInterpreter \* | -                                                                                                                                                                                                                                                                                                                                            | -  |
| agentarts:codeInterpreter:createCoreCodeInterpreter | 授予权限以创建代码解释器。    | 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:codeInterpreter:listCoreCodeInterpreters  | 授予权限以查询代码解释器列表。  | List    | -                  | -                                                                                                                                                                                                                                                                                                                                            | -  |
| agentarts:codeInterpreter:showCoreCodeInterpreter   | 授予权限以查询代码解释器详情。  | Read    | codeInterpreter \* | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts:codeInterpreter:updateCoreCodeInterpreter | 授予权限以更新代码解释器。    | Write   | codeInterpreter \* | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts:codeInterpreter:updateCoreCodeInterpreter | 授予权限以更新代码解释器。    | 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:codeInterpreter:deleteCoreCodeInterpreter | 授予权限以删除代码解释器。    | Write   | codeInterpreter \* | [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                              | 授予权限以批量创建标签。     | Tagging | codeInterpreter \* | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts::tagResource                              | 授予权限以批量创建标签。     | Tagging | -                  | - [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                            | 授予权限以批量删除标签。     | Tagging | codeInterpreter \* | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts::unTagResource                            | 授予权限以批量删除标签。     | Tagging | -                  | - [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::listTagForResource                       | 授予权限以查询资源标签列表。   | List    | codeInterpreter \* | [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)                                                                                                                                                                                                                                                | -  |
| agentarts::listTags                                 | 授予权限以查询标签列表。     | List    | -                  | -                                                                                                                                                                                                                                                                                                                                            | -  |
   
AgentArts的API通常对应着一个或多个授权项。[表2]展示了API与授权项的关系，以及该API需要依赖的授权项。
 表2API与授权项的关系 
| API                                                                                                                                     | 对应的授权项                                              | 依赖的授权项                                                                                                                                                                                                                                                                                                                                                                                              |
|:---|:---|:---|
| [POST /v1/core/code-interpreters](https://support.huaweicloud.com/api-agentarts/CreateCoreCodeInterpreter.html)                         | agentarts:codeInterpreter:createCoreCodeInterpreter | - iam:agencies:pass  - vpc:nativePorts:create  - vpc:routeTables:update  - eip:publicIps:associateInstance   |
| [GET /v1/core/code-interpreters](https://support.huaweicloud.com/api-agentarts/ListCoreCodeInterpreters.html)                           | agentarts:codeInterpreter:listCoreCodeInterpreters  | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [GET /v1/core/code-interpreters/{code_interpreter_id}](https://support.huaweicloud.com/api-agentarts/ShowCoreCodeInterpreter.html)      | agentarts:codeInterpreter:showCoreCodeInterpreter   | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [PUT /v1/core/code-interpreters/{code_interpreter_id}](https://support.huaweicloud.com/api-agentarts/UpdateCoreCodeInterpreter.html)    | agentarts:codeInterpreter:updateCoreCodeInterpreter | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| [DELETE /v1/core/code-interpreters/{code_interpreter_id}](https://support.huaweicloud.com/api-agentarts/DeleteCoreCodeInterpreter.html) | agentarts:codeInterpreter:deleteCoreCodeInterpreter | - vpc:routeTables:update  - vpc:nativePorts:delete  - eip:publicIps:disassociateInstance                                                                                   |
| -                                                                                                                                       | agentarts::listResourcesByTag                       | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::listResourcesByTag                       | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::tagResource                              | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::unTagResource                            | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::listTagForResource                       | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::listTags                                 | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::listResourcesByTag                       | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::listResourcesByTag                       | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::tagResource                              | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::unTagResource                            | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::listTagForResource                       | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::listTags                                 | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::listResourcesByTag                       | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::listResourcesByTag                       | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::tagResource                              | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::unTagResource                            | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::listTagForResource                       | -                                                                                                                                                                                                                                                                                                                                                                                                   |
| -                                                                                                                                       | agentarts::listTags                                 | -                                                                                                                                                                                                                                                                                                                                                                                                   |
   
 #### 资源类型（Resource）
资源类型（Resource）用于定义身份策略生效的资源范围。如[表3]中某项操作已指定了对应的资源类型，则在包含该操作的身份策略语句中选择填写对应资源的URN时，身份策略仅对该指定资源生效；未填写对应资源的URN时，身份策略将对指定资源类型下所有资源生效；如未指定资源类型，Resource默认取值为"\*"，身份策略将作用于所有资源。此外，您也可在身份策略中设置条件，进一步精细化限定资源类型。
AgentArts定义了以下可以在自定义身份策略的Resource元素中使用的资源类型。
 表3AgentArts支持的资源类型 
| 资源类型            | URN                                                                         |
|:---|:---|
| codeInterpreter | agentarts:\<region\>:\<account-id\>:codeInterpreter:\<code_interpreter_id\> |
| browserProfile  | agentarts:\<region\>:\<account-id\>:browserProfile:\<profile_id\>           |
   
 #### 条件（Condition）
AgentArts服务不支持在身份策略中的条件键中配置服务级的条件键。AgentArts可以使用适用于所有服务的全局条件键，请参考[全局条件键](https://support.huaweicloud.com/usermanual-iam5/iam_01_1287.html)。
