CreateControlPolicy

更新时间:
复制 MD 格式

Use CreateControlPolicy to create a custom control policy.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

resourcemanager:CreateControlPolicy

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

PolicyName

string

Yes

The name of the control policy.

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

ExampleControlPolicy

Description

string

No

The description of the control policy.

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

ExampleControlPolicy

EffectScope

string

Yes

The effective scope of the control policy.

Valid value: RAM. This indicates that the control policy applies only to RAM users or RAM roles.

RAM

PolicyDocument

string

Yes

The policy document.

The policy document can be up to 4,096 characters in length.

For more information about the policy language, see Control Policy Language.

For examples, see Examples of Custom Control Policies.

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

Tag

array<object>

No

The tags to attach to the control policy.

object

No

A tag for the control policy.

Key

string

No

The tag key.

k1

Value

string

No

The tag value.

v1

Response elements

Element

Type

Description

Example

object

The data returned.

ControlPolicy

object

The details of the control policy.

AttachmentCount

string

The number of times the control policy is attached.

0

CreateDate

string

The time when the control policy was created.

2021-03-18T09:24:19Z

Description

string

The description of the control policy.

ExampleControlPolicy

EffectScope

string

The scope of the control policy.

Valid value: RAM. This value indicates that the control policy applies only to RAM users and RAM roles.

RAM

PolicyId

string

The ID of the control policy.

cp-jExXAqIYkwHN****

PolicyName

string

The name of the control policy.

ExampleControlPolicy

PolicyType

string

The type of the control policy. Valid values:

  • System: a system control policy.

  • Custom: a custom control policy.

Custom

UpdateDate

string

The time when the control policy was last updated.

2021-03-18T09:24:19Z

ControlPolicyType

string

RESOURCE_CONTROL_POLICY

RequestId

string

The ID of the request.

776B05B3-A0B0-464B-A191-F4E1119A94B2

Examples

Success response

JSON format

{
  "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",
    "ControlPolicyType": "RESOURCE_CONTROL_POLICY"
  },
  "RequestId": "776B05B3-A0B0-464B-A191-F4E1119A94B2"
}

Error codes

HTTP status code

Error code

Error message

Description

409 InvalidParameter.PolicyDocument.Length The maximum length of the policy document is exceeded. It must not exceed 4096 characters.
409 ResourceControlPolicyNotEnabled Resource control policy has not been enabled.
409 InvalidResourceControlPolicyEnablementStatus The resource control policy enablement status is not valid to perform this operation.
409 LimitExceeded.ResourceControlPolicy The resource control policy number exceeds the limit.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.