Creates a tag policy.
Operation description
The following example creates a tag policy named test in multi-account mode. The policy defines that resources tagged with CostCenter:Beijing or CostCenter:Shanghai are compliant and other resources are not compliant.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
tag:CreatePolicy |
create |
*Policy
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
No |
Region ID. Set this to cn-shanghai. |
cn-shanghai |
| PolicyName |
string |
Yes |
The tag policy name. 1 to 128 characters. Supports letters, digits, and underscores (_). |
test |
| PolicyDesc |
string |
No |
The tag policy description. 0 to 512 characters. |
This is a tag policy example. |
| PolicyContent |
string |
Yes |
The tag policy document. For tag policy syntax, see Syntax of a tag policy. |
{"tags":{"CostCenter":{"tag_value":{"@@assign":["Beijing","Shanghai"]},"tag_key":{"@@assign":"CostCenter"}}}} |
| DryRun |
boolean |
No |
Whether to perform a dry run only. Valid values:
|
false |
| UserType |
string |
No |
The Tag Policy feature mode. Valid values:
For details on Tag Policy modes, see Modes of the Tag Policy feature. |
RD |
For common request parameters, see Common parameters.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The returned result. |
||
| RequestId |
string |
The request ID. |
FDBE270D-C491-5EEC-A5CD-98245422D3F7 |
| PolicyId |
string |
The ID of the tag policy. |
p-5732750813924f90**** |
| PolicyName |
string |
The name of the tag policy. |
test |
Examples
Success response
JSON format
{
"RequestId": "FDBE270D-C491-5EEC-A5CD-98245422D3F7",
"PolicyId": "p-5732750813924f90****",
"PolicyName": "test"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | NoPermission.RAM | The operator is not permission for the action in ram policy. | The account is not supported. |
| 403 | EffectivePolicy.ResourceGroupScope.TooLong | The resource group range of for effective policy is too long. | The resource group range for a valid policy is too long. |
| 403 | RDAcount.HasOpened | As the RD master or administrator, you cannot activate the tag policy service because account has already enabled it, you can only activate it once the policy service is disabled by the aforementioned RD account. | The member account of the resource directory has a tag policy. You must disable the member account before you can activate the multi-account mode. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.