All Products
Search
Document Center

Resource Management:CreateControlPolicy

Last Updated:Dec 04, 2024

Creates a custom access control policy.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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.
OperationAccess levelResource typeCondition keyAssociated operation
resourcemanager:CreateControlPolicycreate
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
PolicyNamestringYes

The name of the access control policy.

The name must be 1 to 128 characters in length. The name can contain letters, digits, and hyphens (-) and must start with a letter.

ExampleControlPolicy
DescriptionstringNo

The description of the access control policy.

The description must be 1 to 1,024 characters in length. The description can contain letters, digits, underscores (_), and hyphens (-) and must start with a letter.

ExampleControlPolicy
EffectScopestringYes

The effective scope of the access control policy.

The value RAM indicates that the access control policy takes effect only for RAM users and RAM roles.

RAM
PolicyDocumentstringYes

The document of the access control policy.

The document can be a maximum of 4,096 characters in length.

For more information about the languages of access control policies, see Languages of access control policies.

For more information about the examples of access control policies, see Examples of custom access control policies.

{"Version":"1","Statement":[{"Effect":"Deny","Action":["ram:UpdateRole","ram:DeleteRole","ram:AttachPolicyToRole","ram:DetachPolicyFromRole"],"Resource":"acs:ram:*:*:role/ResourceDirectoryAccountAccessRole"}]}
Tagarray<object>No

The tag to add to the access control policy.

objectNo

The tag to add to the access control policy.

KeystringNo

The tag key.

k1
ValuestringNo

The tag value.

v1

Response parameters

ParameterTypeDescriptionExample
object

The returned result.

ControlPolicyobject

The details of the access control policy.

AttachmentCountstring

The number of times that the access control policy is referenced.

0
CreateDatestring

The time when the access control policy was created.

2021-03-18T09:24:19Z
Descriptionstring

The description of the access control policy.

ExampleControlPolicy
EffectScopestring

The effective scope of the access control policy.

The value RAM indicates that the access control policy takes effect only for RAM users and RAM roles.

RAM
PolicyIdstring

The ID of the access control policy.

cp-jExXAqIYkwHN****
PolicyNamestring

The name of the access control policy.

ExampleControlPolicy
PolicyTypestring

The type of the access control policy. Valid values:

  • System: system access control policy
  • Custom: custom access control policy
Custom
UpdateDatestring

The time when the access control policy was updated.

2021-03-18T09:24:19Z
RequestIdstring

The ID of the request.

776B05B3-A0B0-464B-A191-F4E1119A94B2

Examples

Sample success responses

JSONformat

{
  "ControlPolicy": {
    "AttachmentCount": "0",
    "CreateDate": "2021-03-18T09:24:19Z",
    "Description": "ExampleControlPolicy",
    "EffectScope": "RAM",
    "PolicyId": "cp-jExXAqIYkwHN****",
    "PolicyName": "ExampleControlPolicy",
    "PolicyType": "Custom",
    "UpdateDate": "2021-03-18T09:24:19Z"
  },
  "RequestId": "776B05B3-A0B0-464B-A191-F4E1119A94B2"
}

Error codes

HTTP status codeError codeError message
409InvalidParameter.PolicyDocument.LengthThe maximum length of the policy document is exceeded. It must not exceed 4096 characters.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history