Use Resource Access Management (RAM) to grant different employees specific permissions on API Gateway resources such as API groups, APIs, plug-ins, and applications.
Skip this topic if you do not need permission management for APIs.
-
RAM users can view, create, or delete API groups, APIs, or plug-ins in API Gateway. They do not own these resources — the Alibaba Cloud account can revoke their permissions at any time.
-
Tag-based authorization can isolate resources between the Alibaba Cloud account and RAM users.
-
Before you manage API permissions with RAM, familiarize yourself with RAM and API Gateway. Alibaba Cloud Help Center provides documentation on RAM and API Gateway for you to get familiar with the services.
Policy overview
A policy defines permissions using four elements: Effect, Resource, Action, and Condition.
1. System policy
API Gateway provides two built-in system policies. View them on the Policies page of the RAM console. 
-
AliyunApiGatewayFullAccess: grants full management permissions on all API Gateway resources, including API groups, APIs, throttling policies, and applications.
-
AliyunApiGatewayReadOnlyAccess: grants read-only access to all API Gateway resources, including API groups, APIs, throttling policies, and applications. However, the RAM user cannot manage the resources.
2. Custom policy
Create a custom policy to grant finer-grained permissions on specific actions or resources. For example, you can create a custom policy to grant the edit permissions on GetUsers. To view your custom policies, log on to the RAM console, choose Permissions > Policies, and select Custom Policy from the Policy Type drop-down list.
Policy syntax
A policy uses a specific syntax to define permissions. Attach a policy to a user or group to grant permissions on specific resources.
Example:
{
"Version": "1",
"Statement": [
{
"Action": "apigateway:Describe*",
"Resource": "*",
"Effect": "Allow"
}
]
}
This policy allows a RAM user to query all API Gateway resources.
The Action element describes one or more API operations. The parameters in the Action element must be specified in the following format:
"Action":"<service-name>:<action-name>"
Parameters:
-
service-name: the Alibaba Cloud service name. Set to apigateway for API Gateway.
-
action-name: the name of an API operation. Supports the wildcard character (*). The "Resource syntax" section lists all available operations.
If you set "Action" to "apigateway:Describe*", the authorized RAM user has the permissions to query all resources in API Gateway.
If you set "Action" to "apigateway:*", the authorized RAM user has the permissions to manage all resources in API Gateway.
Resource syntax
The Resource element specifies the objects that a statement covers. In API Gateway, you can specify API groups, throttling policies, and applications. Use the following format:
acs:<service-name>:<region>:<account-id>:<relative-id>
Parameters:
-
acs: the Alibaba Cloud public cloud namespace.
-
service-name: the Alibaba Cloud service name. Set to apigateway for API Gateway.
-
region: the region where the policy applies. Use the wildcard (*) for all regions.
-
account-id: the account ID, such as 123456789012****. Supports the wildcard (*).
-
relative-id: the resource identifier, specified in a file-path-like format.
An RDPath is in one of the following formats:
acs:apigateway:$regionid:$accountid:apigroup/$groupId
Example:
acs:apigateway:*:*:apigroup/cbd157704e624ab58a204fd3e0b5ad79
The following table lists the API operations available for the action-name parameter in API Gateway policies. For more information, see "API Gateway API Reference".
|
action-name |
Description |
Resource |
|
CreateApiGroup |
Creates an API group. |
acs:apigateway:$regionid:$accountid:apigroup/* |
|
ModifyApiGroup |
Modifies an API group. |
acs:apigateway:$regionid:$accountid:apigroup/$groupId |
|
DeleteApiGroup |
Deletes an API group. |
acs:apigateway:$regionid:$accountid:apigroup/$groupId |
|
DescribeApiGroups |
Queries API groups. |
acs:apigateway:$regionid:$accountid:apigroup/* |
|
CreateApi |
Creates an API. |
acs:apigateway:$regionid:$accountid:apigroup/$groupId |
|
DeployApi |
Publishes an API. |
acs:apigateway:$regionid:$accountid:apigroup/$groupId |
|
AbolishApi |
Unpublishes an API. |
acs:apigateway:$regionid:$accountid:apigroup/$groupId |
|
DeleteApi |
Deletes an API. |
acs:apigateway:$regionid:$accountid:apigroup/$groupId |
|
DescribeApis |
Queries APIs. |
acs:apigateway:$regionid:$accountid:apigroup/* |
|
CreatePlugin |
Creates a plug-in. |
acs:apigateway:$regionid:$accountid:plugin/* |
|
ModifyPlugin |
Modifies a plug-in. |
acs:apigateway:$regionid:$accountid:plugin/$pluginId |
|
DeletePlugin |
Deletes a plug-in. |
acs:apigateway:$regionid:$accountid:plugin/$pluginId |
|
AttachPlugin |
Binds a plug-in to an API. |
acs:apigateway:$regionid:$accountid:plugin/$pluginId |
|
DetachPlugin |
Unbinds a plug-in from an API. |
acs:apigateway:$regionid:$accountid:plugin/$pluginId |
|
DescribePluginsByApi |
Queries plug-ins that are bound to an API. |
acs:apigateway:$regionid:$accountid:plugin/$pluginId |
|
CreateApp |
Creates an application. |
acs:apigateway:$regionid:$accountid:app/* |
|
ModifyApp |
Modifies an application. |
acs:apigateway:$regionid:$accountid:app/$appId |
|
DeleteApp |
Deletes an application. |
acs:apigateway:$regionid:$accountid:app/$appId |
|
DescribeAppAttributes |
Queries applications. |
acs:apigateway:$regionid:$accountid:app/$appId |
|
SetApisAuthorities |
Authorizes an application to call APIs. |
acs:apigateway:$regionid:$accountid:apigroup/$groupId |
|
DescribeAuthorizedApps |
Queries applications that are authorized to call an API. |
acs:apigateway:$regionid:$accountid:apigroup/$groupId |
|
SetVpcAccess |
Creates a virtual private cloud (VPC) access authorization. |
acs:apigateway:$regionid:$accountid:vpcaccess/* |
|
RemoveVpcAccess |
Deletes a VPC access authorization. |
acs:apigateway:$regionid:$accountid:vpcaccess/* |
|
DescribeVpcAccesses |
Queries VPC access authorizations. |
acs:apigateway:$regionid:$accountid:vpcaccess/* |
|
DescribeInstances |
Queries dedicated instances. |
acs:apigateway:$regionid:$accountid:instance/$instanceId |
Examples
Authorize a RAM user to query all APIs:
{
"Version": "1",
"Statement": [
{
"Action": "apigateway:Describe*",
"Resource":"acs:apigateway:$regionid:$accountid:apigroup/*",
"Effect": "Allow"
}
]
}
Authorize a RAM user to query all API groups to which the `version:v1` tag is attached:
{
"Version": "1",
"Statement": [
{
"Action": "apigateway:Describe*",
"Resource":"acs:apigateway:$regionid:$accountid:apigroup/*",
"Effect": "Allow",
"Condition": {
"StringEquals": {
"apigateway:tag/version": "v1"
}
}
}
]
}
Authorize a RAM user to manage all APIs in an API group:
{
"Version": "1",
"Statement": [
{
"Action": "apigateway:*",
"Resource": [
"acs:apigateway:$regionid:$accountid:apigroup/$groupId",
"acs:apigateway:$regionid:$accountid:app/$appId",
"acs:apigateway:$regionid:$accountid:vpcaccess/*"
],
"Effect": "Allow"
}
]
}
Note: In the preceding examples, you can specify the wildcard character (*) for variables based on your business requirements.