Attaches a custom control policy. After you attach a custom control policy, the operations performed on resources by using member accounts are limited by the custom control policy.

The control policy that is attached to a folder also applies to all its child folders and all member accounts in the child folders.

A maximum of 10 custom control policies can be attached to a folder or member account.

In this example, the custom control policy cp-jExXAqIYkwHN**** is attached to the folder fd-ZDNPiT****.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes AttachControlPolicy

The operation that you want to perform. Set the value to AttachControlPolicy.

PolicyId String Yes cp-jExXAqIYkwHN****

The ID of the control policy.

TargetId String Yes fd-ZDNPiT****

The ID of the object to which you want to attach the control policy. Control policies can be attached to the following objects:

  • Root folder
  • Child folders of the Root folder
  • Member accounts

For more information about common request parameters, see Common parameters.

Response parameters

Parameter Type Example Description
RequestId String 95060F1D-6990-4645-8920-A81D1BBFE992

The ID of the request.

Examples

Sample requests

https://resourcemanager.aliyuncs.com/?Action=AttachControlPolicy
&PolicyId=cp-jExXAqIYkwHN****
&TargetId=fd-ZDNPiT****
&<Common request parameters>

Sample success responses

XML format

<AttachControlPolicyResponse>
	  <RequestId>95060F1D-6990-4645-8920-A81D1BBFE992</RequestId>
</AttachControlPolicyResponse>

JSON format

{
  "RequestId": "95060F1D-6990-4645-8920-A81D1BBFE992"
}

Error codes

HTTP status code Error code Error message Description
404 EntityNotExists.Target The specified target does not exist in the resource directory. The error message returned because the specified object does not exist in the resource directory.

For a list of error codes, visit the API Error Center.