访问控制(RAM)是阿里云提供的管理用户身份与资源访问权限的服务。使用 RAM 可以让您避免与其他用户共享阿里云账号密钥,并可按需为用户授予最小权限。RAM 中使用权限策略描述授权的具体内容。
本文为您介绍 API 网关 为 RAM 权限策略定义的操作(Action)、资源(Resource)和条件(Condition)。 API 网关 的 RAM 代码(RamCode)为 apig ,支持的授权粒度为 资源级 。各操作的资源授权范围见操作表。
权限策略通用结构
权限策略支持 JSON 格式。以下为使用 Action 元素的权限策略结构示意,尖括号内为占位符,使用时需替换为实际值:
{
"Version": "1",
"Statement": [
{
"Effect": "<Effect>",
"Action": "<Action>",
"Resource": "<Resource>",
"Condition": {
"<Condition_operator>": {
"<Condition_key>": [
"<Condition_value>"
]
}
}
}
]
}
各字段及占位符含义如下:
-
Effect:权限策略效果。取值:Allow(允许)、Deny(拒绝)。
-
Action:允许或拒绝的具体操作。具体信息,请参见操作(Action)。
-
Resource:受操作影响的具体对象,您可以使用资源 ARN 来描述指定资源。具体信息,请参见资源(Resource)。
-
Condition:策略语句生效的条件。可选字段。具体信息,请参见条件(Condition)。
-
Condition_operator:条件运算符,不同类型的条件对应不同的条件运算符。具体信息,请参见权限策略基本元素。
-
Condition_key:条件关键字。
-
Condition_value:条件关键字对应的值。
操作(Action)
下表列出API 网关的 RAM 操作,这些操作可以在 RAM 权限策略的 Action 元素中使用。
-
操作:具体的 RAM 权限点,大部分情况下和 OpenAPI 同名。
-
OpenAPI:与该 RAM 操作关联的 OpenAPI。
-
访问级别:是指每个操作的访问级别。取值:create、list、get、update、delete。
-
资源类型:是指操作中支持授权的资源类型。具体说明如下:
-
对于必选的资源类型,用前面加 * 表示。
-
对于不支持资源级授权的操作,用
全部资源表示。显示“全部资源”且资源 ARN 为 * 时,权限策略中的 Resource 填写 *。
-
-
条件关键字:操作支持的产品级条件关键字,不含通用条件关键字。
-
关联操作:执行该操作还需要具备的其他操作权限。
|
操作 |
OpenAPI |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
| apig:CreateConsumerGroup | CreateConsumerGroup | create |
*全部资源
|
无 | 无 |
| apig:CreateRiskCheckTask | CreateRiskCheckTask | create |
*Gateway
|
无 | 无 |
| apig:ListHttpApiRoutes | ListHttpApiRoutes | list |
*HttpApi
|
无 | 无 |
| apig:ListBatchExportTasks | ListBatchExportTasks | list |
*全部资源
|
无 | 无 |
| apig:CreateConsumer | CreateConsumer | create |
*全部资源
|
无 | 无 |
| apig:GetResourceOverview | GetResourceOverview | get |
*全部资源
|
无 | 无 |
| apig:GetConsumer | GetConsumer | none |
*Domain
|
无 | 无 |
| apig:UpdateEnvironment | UpdateEnvironment | none |
*Environment
|
无 | 无 |
| apig:ListPlugins | ListPlugins | none |
*全部资源
|
无 | 无 |
| apig:ListPolicyClasses | ListPolicyClasses | none |
*全部资源
|
无 | 无 |
| apig:GetBatchExportTask | GetBatchExportTask | none |
*全部资源
|
无 | 无 |
| apig:ListGatewayLoadBalancers | ListGatewayLoadBalancers | none |
*Gateway
|
无 | 无 |
| apig:GetBatchImportTask | GetBatchImportTask | none |
*全部资源
|
无 | 无 |
| apig:GetPolicyAttachment | GetPolicyAttachment | get |
*全部资源
|
无 | 无 |
| apig:BatchAddConsumerGroupConsumers | BatchAddConsumerGroupConsumers | none |
*全部资源
|
无 | 无 |
| apig:ListRiskCheckResults | ListRiskCheckResults | list |
*HttpApi
|
无 | 无 |
| apig:GetHttpApi | GetHttpApi | get |
*HttpApi
|
无 | 无 |
| apig:DeleteHttpApi | DeleteHttpApi | delete |
*HttpApi
|
无 | 无 |
| apig:GetHttpApiRoute | GetHttpApiRoute | none |
*HttpApi
|
无 | 无 |
| apig:RunPluginPipeline | RunPluginPipeline | none |
*全部资源
|
无 | 无 |
| apig:DeleteGatewaySecurityGroupRule | DeleteGatewaySecurityGroupRule | none |
*Gateway
|
无 | 无 |
| apig:UninstallPlugin | UninstallPlugin | none |
*全部资源
|
无 | 无 |
| apig:UpgradeGateway | UpgradeGateway | none |
*Gateway
|
无 | 无 |
| apig:AddGatewaySecurityGroupRule | AddGatewaySecurityGroupRule | none |
*Gateway
|
无 | 无 |
| apig:UpdateGatewayElasticPolicy | UpdateGatewayElasticPolicy | update |
*Gateway
|
无 | 无 |
| apig:BatchDeleteConsumerAuthorizationRule | BatchDeleteConsumerAuthorizationRule | delete |
*全部资源
|
无 | 无 |
| apig:ListTagResources | ListTagResources | none |
*全部资源
|
无 | 无 |
| apig:GetPolicy | GetPolicy | get |
*Policy
|
无 | 无 |
| apig:RefreshPluginOAuthCode | RefreshPluginOAuthCode | none |
*全部资源
|
无 | 无 |
| apig:UpdateGatewayQuotaRule | UpdateGatewayQuotaRule | update |
*Gateway
|
无 | 无 |
| apig:GetGatewayQuotaRuleSubjectUsage | GetGatewayQuotaRuleSubjectUsage | none |
*Gateway
|
无 | 无 |
| apig:UpdateConsumerGroup | UpdateConsumerGroup | none |
*全部资源
|
无 | 无 |
| apig:GetConsumerAuthorizationRule | GetConsumerAuthorizationRule | none |
*Domain
|
无 | 无 |
| apig:ListDomains | ListDomains | none |
*Domain
|
无 | 无 |
| apig:BatchRemoveConsumerGroupConsumers | BatchRemoveConsumerGroupConsumers | none |
*全部资源
|
无 | 无 |
| apig:UpdateConsumer | UpdateConsumer | none |
*Domain
|
无 | 无 |
| apig:ResetGatewayQuotaRule | ResetGatewayQuotaRule | none |
*Gateway
|
无 | 无 |
| apig:DeletePluginClass | DeletePluginClass | none |
*全部资源
|
无 | 无 |
| apig:DescribeRegions | DescribeRegions | none |
*全部资源
|
无 | 无 |
| apig:DeleteService | DeleteService | none |
*Service
|
无 | 无 |
| apig:CreatePluginAttachment | CreatePluginAttachment | none |
*全部资源
|
无 | 无 |
| apig:ListConsumerGroups | ListConsumerGroups | none |
*全部资源
|
无 | 无 |
| apig:UpdateGatewayQuotaRuleStatus | UpdateGatewayQuotaRuleStatus | none |
*Gateway
|
无 | 无 |
| apig:CreateHttpApiOperation | CreateHttpApiOperation | create |
*HttpApi
|
无 | 无 |
| apig:ListSyncMCPServer | ListSyncMCPServer | none |
*全部资源
|
无 | 无 |
| apig:CreatePolicyAttachment | CreatePolicyAttachment | create |
*全部资源
|
无 | 无 |
| apig:GetPluginWorkspace | GetPluginWorkspace | none |
*全部资源
|
无 | 无 |
| apig:DeleteServiceVersion | DeleteServiceVersion | delete |
*Service
|
无 | 无 |
| apig:UpdateGatewayFeature | UpdateGatewayFeature | none |
*Gateway
|
无 | 无 |
| apig:ListMigrationTasks | ListMigrationTasks | list |
*全部资源
|
无 | 无 |
| apig:ListHttpApiOperations | ListHttpApiOperations | list |
*HttpApi
|
无 | 无 |
| apig:CreatePluginWorkspace | CreatePluginWorkspace | none |
*全部资源
|
无 | 无 |
| apig:DeleteConsumer | DeleteConsumer | none |
*Domain
|
无 | 无 |
| apig:ListPluginWorkspace | ListPluginWorkspace | none |
*全部资源
|
无 | 无 |
| apig:GetDomain | GetDomain | get |
*Domain
|
无 | 无 |
| apig:CreateHttpApiVersion | CreateHttpApiVersion | create |
*全部资源
|
无 | 无 |
| apig:DeletePluginAttachment | DeletePluginAttachment | none |
*全部资源
|
无 | 无 |
| apig:ListExternalServices | ListExternalServices | none |
*Gateway
|
无 | 无 |
| apig:ListPluginClasses | ListPluginClasses | none |
*全部资源
|
无 | 无 |
| apig:GetDashboard | GetDashboard | get |
*全部资源
|
无 | 无 |
| apig:CreateGateway | CreateGateway | create |
*Gateway
|
无 | 无 |
| apig:CreateConsumerAuthorizationRule | CreateConsumerAuthorizationRule | none |
*Domain
|
无 | 无 |
| apig:UpdateConsumerAuthorizationRule | UpdateConsumerAuthorizationRule | none |
*Domain
|
无 | 无 |
| apig:GetPluginAttachment | GetPluginAttachment | get |
*全部资源
|
无 | 无 |
| apig:ChangeResourceGroup | ChangeResourceGroup | none |
*Domain
*Gateway
*Source
*Service
*Environment
*HttpApi
|
无 | 无 |
| apig:GetConsumerGroup | GetConsumerGroup | none |
*全部资源
|
无 | 无 |
| apig:ListConsumerGroupConsumers | ListConsumerGroupConsumers | none |
*全部资源
|
无 | 无 |
| apig:CreateMigrationTask | CreateMigrationTask | create |
*全部资源
|
无 | 无 |
| apig:ListServices | ListServices | none |
*Service
|
无 | 无 |
| apig:BatchExportHttpApis | BatchExportHttpApis | none |
*全部资源
|
无 | 无 |
| apig:UpdateHttpApiOperation | UpdateHttpApiOperation | update |
*HttpApi
|
无 | 无 |
| apig:ListGlobalPolicies | ListGlobalPolicies | none |
*全部资源
|
无 | 无 |
| apig:DeleteMigrationTask | DeleteMigrationTask | delete |
*全部资源
|
无 | 无 |
| apig:DeleteHttpApiRoute | DeleteHttpApiRoute | none |
*HttpApi
|
无 | 无 |
| apig:DeleteConsumerGroup | DeleteConsumerGroup | none |
*全部资源
|
无 | 无 |
| apig:ListConsumerQuotaRules | ListConsumerQuotaRules | none |
*Domain
|
无 | 无 |
| apig:UpdatePluginAttachment | UpdatePluginAttachment | none |
*全部资源
|
无 | 无 |
| apig:UpdateRiskNotification | UpdateRiskNotification | create |
*Gateway
|
无 | 无 |
| apig:GetGatewayElasticPolicy | GetGatewayElasticPolicy | get |
*Gateway
|
无 | 无 |
| apig:CreateAndAttachPolicy | CreateAndAttachPolicy | none |
*Policy
|
无 | 无 |
| apig:GetGatewayResourceQuotaUsage | GetGatewayResourceQuotaUsage | get |
*Gateway
|
无 | 无 |
| apig:CreateSource | CreateSource | none |
*全部资源
|
无 | 无 |
| apig:GetTraceConfig | GetTraceConfig | get |
*全部资源
|
无 | 无 |
| apig:ListPluginRepositories | ListPluginRepositories | none |
*全部资源
|
无 | 无 |
| apig:DeleteGatewayQuotaRule | DeleteGatewayQuotaRule | none |
*Gateway
|
无 | 无 |
| apig:UpdateHttpApiRoute | UpdateHttpApiRoute | none |
*HttpApi
|
无 | 无 |
| apig:UpdateHttpApi | UpdateHttpApi | update |
*HttpApi
|
无 | 无 |
| apig:DeleteEnvironment | DeleteEnvironment | none |
*Environment
|
无 | 无 |
| apig:ListSources | ListSources | none |
*Source
|
无 | 无 |
| apig:ExportHttpApi | ExportHttpApi | none |
*HttpApi
|
无 | 无 |
| apig:ListGatewayErrorAccessLogs | ListGatewayErrorAccessLogs | list |
*全部资源
|
无 | 无 |
| apig:DeployHttpApi | DeployHttpApi | none |
*HttpApi
|
无 | 无 |
| apig:ListHttpApis | ListHttpApis | list |
*HttpApi
|
无 | 无 |
| apig:ListGatewayQuotaRules | ListGatewayQuotaRules | list |
*Gateway
|
无 | 无 |
| apig:DeleteDomain | DeleteDomain | delete |
*Domain
|
无 | 无 |
| apig:CreateDomain | CreateDomain | create |
*Domain
|
无 | 无 |
| apig:GetEnvironment | GetEnvironment | none |
*Environment
|
无 | 无 |
| apig:CreateSecret | CreateSecret | create |
*全部资源
|
无 | 无 |
| apig:DeletePolicyAttachment | DeletePolicyAttachment | delete |
*全部资源
|
无 | 无 |
| apig:ListInstallableGateways | ListInstallableGateways | none |
*全部资源
|
无 | 无 |
| apig:DeletePolicy | DeletePolicy | delete |
*全部资源
|
无 | 无 |
| apig:UpdateGatewayMaintenancePeriod | UpdateGatewayMaintenancePeriod | none |
*Gateway
|
无 | 无 |
| apig:UpdateAndAttachPolicy | UpdateAndAttachPolicy | none |
*Policy
|
无 | 无 |
| apig:BatchImportHttpApis | BatchImportHttpApis | none |
*全部资源
|
无 | 无 |
| apig:CreateServiceVersion | CreateServiceVersion | create |
*全部资源
|
无 | 无 |
| apig:GetRiskNotification | GetRiskNotification | get |
*HttpApi
|
无 | 无 |
| apig:RemoveConsumerAuthorizationRule | RemoveConsumerAuthorizationRule | none |
*全部资源
|
无 | 无 |
| apig:TagResources | TagResources | none |
*Gateway
|
无 | 无 |
| apig:CreatePolicy | CreatePolicy | none |
*全部资源
|
无 | 无 |
| apig:RestartGateway | RestartGateway | none |
*Gateway
|
无 | 无 |
| apig:ImportHttpApi | ImportHttpApi | none |
*全部资源
|
无 | 无 |
| apig:UpdateNetworkAccess | UpdateNetworkAccess | none |
*Gateway
|
无 | 无 |
| apig:CreateHttpApiRoute | CreateHttpApiRoute | none |
*HttpApi
|
无 | 无 |
| apig:GetPluginClass | GetPluginClass | none |
*全部资源
|
无 | 无 |
| apig:GetGateway | GetGateway | get |
*Gateway
|
无 | 无 |
| apig:UpdateMigrationTask | UpdateMigrationTask | update |
*全部资源
|
无 | 无 |
| apig:ListConsumerGroupQuotaRules | ListConsumerGroupQuotaRules | none |
*全部资源
|
无 | 无 |
| apig:UntagResources | UntagResources | none |
*Gateway
|
无 | 无 |
| apig:GetMigrationNamespacedServices | GetMigrationNamespacedServices | get |
*全部资源
|
无 | 无 |
| apig:UpdateService | UpdateService | none |
*Service
|
无 | 无 |
| apig:CreateHttpApi | CreateHttpApi | create |
*HttpApi
|
无 | 无 |
| apig:ListEnvironments | ListEnvironments | list |
*Environment
|
无 | 无 |
| apig:UpdateAuthorizationRule | UpdateAuthorizationRule | update |
*全部资源
|
无 | 无 |
| apig:CreateEnvironment | CreateEnvironment | none |
*Environment
|
无 | 无 |
| apig:ListPolicies | ListPolicies | none |
*全部资源
|
无 | 无 |
| apig:CreatePluginClass | CreatePluginClass | none |
*全部资源
|
无 | 无 |
| apig:ListGateways | ListGateways | list |
*Gateway
|
无 | 无 |
| apig:BatchUpdateHttpApiOperation | BatchUpdateHttpApiOperation | update |
*HttpApi
|
无 | 无 |
| apig:ListPluginAttachments | ListPluginAttachments | none |
*全部资源
|
无 | 无 |
| apig:UndeployHttpApi | UndeployHttpApi | none |
*HttpApi
|
无 | 无 |
| apig:DeleteSecret | DeleteSecret | none |
*Domain
|
无 | 无 |
| apig:UpdatePolicy | UpdatePolicy | update |
*全部资源
|
无 | 无 |
| apig:DeleteSource | DeleteSource | none |
*Source
|
无 | 无 |
| apig:ListZones | ListZones | none |
*全部资源
|
无 | 无 |
| apig:InstallPlugin | InstallPlugin | none |
*全部资源
|
无 | 无 |
| apig:GetSecret | GetSecret | none |
*Domain
|
无 | 无 |
| apig:ListK8sClusterSources | ListK8sClusterSources | none |
*Gateway
|
无 | 无 |
| apig:UpdateDomain | UpdateDomain | none |
*Domain
|
无 | 无 |
| apig:DeleteGateway | DeleteGateway | delete |
*Gateway
|
无 | 无 |
| apig:ListGatewayFeatures | ListGatewayFeatures | none |
*Gateway
|
无 | 无 |
| apig:ListConsumers | ListConsumers | list |
*全部资源
|
无 | 无 |
| apig:CreateService | CreateService | none |
*Service
|
无 | 无 |
| apig:QueryConsumerAuthorizationRules | QueryConsumerAuthorizationRules | none |
*全部资源
|
无 | 无 |
| apig:ListConsumerAuthorizationRules | ListConsumerAuthorizationRules | none |
*Domain
|
无 | 无 |
| apig:GetService | GetService | none |
*Service
|
apig:GatewayId |
无 |
| apig:InvokeAIAgent | InvokeAIAgent | none |
*全部资源
|
无 | 无 |
| apig:GetHttpApiOperation | GetHttpApiOperation | get |
*HttpApi
|
无 | 无 |
| apig:ListSecrets | ListSecrets | list |
*全部资源
|
无 | 无 |
| apig:UpdateSecret | UpdateSecret | none |
*Domain
|
无 | 无 |
| apig:AddGatewayQuotaRule | AddGatewayQuotaRule | none |
*Gateway
|
无 | 无 |
| apig:GetSource | GetSource | get |
*全部资源
|
apig:GatewayId |
无 |
| apig:VerifyMigrationTask | VerifyMigrationTask | none |
*全部资源
|
无 | 无 |
| apig:UpdateGatewayLoadBalancer | UpdateGatewayLoadBalancer | none |
*Gateway
|
无 | 无 |
| apig:GetGatewayQuotaRule | GetGatewayQuotaRule | get |
*Gateway
|
无 | 无 |
| apig:UpdateServiceVersion | UpdateServiceVersion | update |
*Service
|
无 | 无 |
| apig:DeleteConsumerAuthorizationRule | DeleteConsumerAuthorizationRule | none |
*Domain
|
无 | 无 |
| apig:ListSslCerts | ListSslCerts | none |
*全部资源
|
无 | 无 |
| apig:UpdateGatewayName | UpdateGatewayName | update |
*Gateway
|
无 | 无 |
| apig:GetSecretValue | GetSecretValue | none |
*全部资源
|
无 | 无 |
| apig:ListSecretReferences | ListSecretReferences | list |
*Domain
|
无 | 无 |
| apig:CreateConsumerAuthorizationRules | CreateConsumerAuthorizationRules | none |
*全部资源
|
无 | 无 |
| apig:GetMigrationTask | GetMigrationTask | get |
*全部资源
|
无 | 无 |
| apig:DeleteHttpApiOperation | DeleteHttpApiOperation | delete |
*HttpApi
|
无 | 无 |
资源(Resource)
下表列出API 网关的资源类型及其 ARN 格式。RAM 权限策略语句的 Resource 元素用于指定该语句适用的资源。具体说明如下:
-
{#}为变量标识,需要您替换为实际值。例如:{#ramcode}需要您替换为实际的云服务RAM代码。 -
*表示全部。例如:-
{#resourceType}为*时:表示全部资源。 -
{#regionId}为*时:表示全部地域。 -
{#accountId}为*时:表示全部阿里云账号。
-
资源类型 |
资源 ARN |
| Domain |
|
| Gateway |
|
| HttpApi |
|
| Environment |
|
| Portal |
|
| ConsumerAuthorizationRule |
|
| Policy |
|
| Product |
|
| Service |
|
| Source |
|
条件(Condition)
下表列出API 网关定义的产品级条件关键字,可在 RAM 权限策略语句的 Condition 元素中指定策略语句生效的条件。请使用与条件关键字的数据类型相适用的条件运算符。条件运算符不匹配时,该策略语句不生效。条件运算符的说明,请参见条件运算符。
条件关键字 |
描述 |
类型 |
| apig:GatewayId | 网关ID |
Array |
| apig:NetworkType | 网络类型 |
Array |
相关文档
关于条件运算符、自定义权限策略与授权操作,请参见以下文档: