Creates an automatic resource group transfer rule. Two types are supported: custom transfer rules and attached-resource transfer rules.
Operation description
You can create up to 10 custom transfer rules, and each custom transfer rule supports up to 10 rule entries.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
resourcemanager:CreateAutoGroupingRule |
create |
*All Resource
|
None | None |
Request syntax
POST HTTP/1.1
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RuleName |
string |
Yes |
The rule name. |
Auto transfer rule for Project A online resources |
| RuleDesc |
string |
No |
The rule description. |
Transfer resources with tags {"env": "online"} and {"project": "A"} to resource group rg-aek2********qcy |
| RuleType |
string |
Yes |
The rule type. Valid values:
Valid values:
|
custom_condition |
| RuleContents |
array<object> |
Yes |
The list of rule entries. |
|
|
object |
No |
The rule entry. |
||
| AutoGroupingScopeCondition |
string |
No |
The scope condition for automatic resource group transfer. Specifies the scope of resources to be automatically transferred. |
{"children":[{"desired":"{\"env\":\"online\", \"project\":\"A\"}","featurePath":"$.tags","featureSource":"RESOURCE","operator":"TagMatchAll"}],"operator":"and"} |
| TargetResourceGroupCondition |
string |
Yes |
The target resource group condition. Specifies the destination resource group for automatic grouping. |
{"children":[{"desired":"rg-aek2********qcy","featurePath":"$.resourceGroupId","featureSource":"RESOURCE","operator":"StringEquals"}],"operator":"and"} |
| ResourceGroupIdsScope |
string |
No |
The scope of resource group IDs. Separate multiple resource group IDs with commas (,). |
rg-aekz******4b5ea,rg-aek2******fxykq |
| ExcludeResourceGroupIdsScope |
string |
No |
The resource group IDs to exclude. Separate multiple resource group IDs with commas (,). |
rg-aekz******zj2oi,rg-aekz******r62ua |
| RegionIdsScope |
string |
No |
The scope of region IDs. Separate multiple region IDs with commas (,). |
cn-hangzhou,cn-shanghai |
| ExcludeRegionIdsScope |
string |
No |
The region IDs to exclude. Separate multiple region IDs with commas (,). |
cn-beijing,cn-guangzhou |
| ResourceIdsScope |
string |
No |
The scope of resource IDs. Separate multiple resource IDs with commas (,). |
i-2zee******ym49kfmwis,vpc-5ts6******fnw493g849a |
| ExcludeResourceIdsScope |
string |
No |
The resource IDs to exclude. Separate multiple resource IDs with commas (,). |
pc-uf6p******4h784y,rmq-cn-******ny0y |
| ResourceTypesScope |
string |
No |
The scope of resource types. Separate multiple resource types with commas (,). |
rds.dbinstance,oss.bucket |
| ExcludeResourceTypesScope |
string |
No |
The resource types to exclude. Separate multiple resource types with commas (,). |
mse.cluster,slb.loadbalancer |
Example 1: Automatically transfer resources based on resource tags
{
"RuleName": "Auto transfer for Project A online resources",
"RuleDesc": "Transfer resources with tags {\"env\": \"online\"} and {\"project\": \"A\"} to resource group rg-aek2********qcy",
"RuleType": "custom_condition",
"RuleContents": [
{
"AutoGroupingScopeCondition": "{\"children\":[{\"desired\":\"{\\\"env\\\":\\\"online\\\", \\\"project\\\":\\\"A\\\"}\",\"featurePath\":\"$.tags\",\"featureSource\":\"RESOURCE\",\"operator\":\"TagMatchAll\"}],\"operator\":\"and\"}",
"TargetResourceGroupCondition": "{\"children\":[{\"desired\":\"rg-aek2********qcy\",\"featurePath\":\"$.resourceGroupId\",\"featureSource\":\"RESOURCE\",\"operator\":\"StringEquals\"}],\"operator\":\"and\"}"
}
]
}
Example 2: Transfer cloud disks along with ECS instances
{
"RuleName": "Transfer cloud disks along with ECS instances",
"RuleDesc": "When a cloud disk is attached to an ECS instance or an ECS instance is transferred to another resource group, the associated cloud disks are automatically transferred to the resource group of the associated ECS instance",
"RuleType": "associated_transfer",
"ResourceTypesScope": "ecs.disk",
"RuleContents": [
{
"TargetResourceGroupCondition": "{\"desired\":\"$.ResourceGroupId\",\"desiredSource\":\"RESOURCE_RELATIONSHIP_ACS::ECS::Instance\",\"featurePath\":\"$.ResourceGroupId\",\"featureSource\":\"CONFIGURATION\",\"operator\":\"StringEquals\"}"
}
]
}
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response parameters. |
||
| RequestId |
string |
The request ID. |
F7701451-340B-5CB3-AEA7-7D831F7F38C0 |
| RuleId |
string |
The rule ID. |
gr-acfo******hy6a |
Examples
Success response
JSON format
{
"RequestId": "F7701451-340B-5CB3-AEA7-7D831F7F38C0",
"RuleId": "gr-acfo******hy6a"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | Invalid.AssociatedTransferRule.AlreadyExisted | The associated transfer rule already exists. | The associated transfer rule already exists. |
| 400 | InvalidParameter.ResourceTypesScope | The parameter ResourceTypesScope is invalid. | The parameter ResourceTypesScope is invalid. |
| 400 | InvalidParameter.ExcludeResourceTypesScope | The parameter ExcludeResourceTypesScope is invalid. | The parameter ExcludeResourceTypesScope is invalid. |
| 400 | InvalidParameter.ResourceGroupIdsScope | The parameter ResourceGroupIdsScope is invalid. | The parameter ResourceGroupIdsScope is invalid. |
| 400 | InvalidParameter.ExcludeResourceGroupIdsScope | The parameter ExcludeResourceGroupIdsScope is invalid. | The parameter ExcludeResourceGroupIdsScope is invalid. |
| 400 | InvalidParameterCombination.BothRegionIdScopes | The combination of parameters RegionIdsScope and ExcludeRegionIdsScope is not allowed. Please select only one of these parameters. | RegionIdsScope and ExcludeRegionIdsScope are mutually exclusive. Only one of these parameters can be specified in the same request. |
| 400 | InvalidParameterCombination.BothResourceGroupIdScopes | The combination of parameters ResourceGroupIdsScope and ExcludeResourceGroupIdsScope is not allowed. Please select only one of these parameters. | ResourceGroupIdsScope and ExcludeResourceGroupIdsScope are mutually exclusive. Only one of these parameters can be specified in the same request. |
| 400 | InvalidParameterCombination.BothResourceIdScopes | The combination of parameters ResourceIdsScope and ExcludeResourceIdsScope is not allowed. Please select only one of these parameters. | ResourceIdsScope and ExcludeResourceIdsScope are mutually exclusive. Only one of these parameters can be specified in the same request. |
| 400 | InvalidParameterCombination.BothResourceTypeScopes | The combination of parameters ResourceTypesScope and ExcludeResourceTypesScope is not allowed. Please select only one of these parameters. | ResourceTypesScope and ExcludeResourceTypesScope are mutually exclusive. Only one of these parameters can be specified in the same request. |
| 400 | InvalidParameter.RuleContents | The parameter RuleContents is invalid. | The parameter RuleContents is invalid. |
| 400 | MissingParameter.RuleContents | The parameter RuleContents is required. | The parameter RuleContents is required. |
| 409 | AutoGroupingNotEnabled | The auto grouping is disabled. | The auto grouping is disabled. |
| 409 | QuotaExceeded.RuleContent | The number of rule contents exceeds the quota. | The number of rule contents exceeds the quota. |
| 409 | QuotaExceeded.GroupingRule | The number of grouping rules exceeds the quota. | The number of grouping rules exceeds the quota. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.