Creates a custom policy.
Operation description
For more information about policies, see Policy overview.
This topic provides an example on how to create a custom policy to query Elastic Compute Service (ECS) instances in a specific region.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
ram:CreatePolicy | create |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
PolicyName | string | Yes | The name of the policy. The name must be 1 to 128 characters in length, and can contain letters, digits, and hyphens (-). | View-ECS-instances-in-a-specific-region |
Description | string | No | The description of the policy. The description must be 1 to 1,024 characters in length. | Query ECS instances in a specific region |
PolicyDocument | string | Yes | The document of the policy. The document must be 1 to 6,144 characters in length. For more information about policy elements and sample policies, see Policy elements and Overview of sample policies. | {"Statement": [{"Effect": "Allow","Action": "ecs:Describe*","Resource": "acs:ecs:cn-qingdao:*:instance/*"}],"Version": "1"} |
Response parameters
Examples
Sample success responses
JSON
format
{
"Policy": {
"DefaultVersion": "v1",
"Description": "Query ECS instances in a specific region",
"PolicyName": "View-ECS-instances-in-a-specific-region",
"CreateDate": "2021-10-13T02:46:57Z",
"PolicyType": "Custom"
},
"RequestId": "BA34C54A-C2B1-5A65-B6B0-B5842C1DB4DA"
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|