All Products
Search
Document Center

Resource Management:CreateAutoGroupingRule

Last Updated:Dec 15, 2025

Creates a transfer rule. Custom transfer rules and transfer rules for associated resources are supported.

Operation description

You can create up to 10 custom transfer rules. Each custom transfer rule can contain up to 10 content records.

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:
    • For mandatory resource types, indicate with a prefix of * .
    • 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:CreateAutoGroupingRulecreate
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
RuleNamestringYes

The name of the rule.

Custom Transfer Rule for Online Resources of Project A
RuleDescstringNo

The description of the rule.

Transfer resources to which the {"env": "online"} and {"project": "A"} tags are added to the resource group rg-aek2********qcy.
RuleTypestringYes

The type of the rule. Valid values:

  • custom_condition: custom transfer rule
  • associated_transfer: transfer rule for associated resources
custom_condition
RuleContentsarray<object>Yes

The content records of the rule.

objectYes

The content record of the rule.

AutoGroupingScopeConditionstringNo

The condition for the range of resources to be automatically transferred.

{"children":[{"desired":"{\"env\":\"online\", \"project\":\"A\"}","featurePath":"$.tags","featureSource":"RESOURCE","operator":"TagMatchAll"}],"operator":"and"}
TargetResourceGroupConditionstringYes

The condition for the destination resource group.

{"children":[{"desired":"rg-aek2********qcy","featurePath":"$.resourceGroupId","featureSource":"RESOURCE","operator":"StringEquals"}],"operator":"and"}
ResourceGroupIdsScopestringNo

The IDs of resource groups. Separate multiple IDs with commas (,).

rg-aekz******4b5ea,rg-aek2******fxykq
ExcludeResourceGroupIdsScopestringNo

The IDs of resource groups to be excluded. Separate multiple IDs with commas (,).

rg-aekz******zj2oi,rg-aekz******r62ua
RegionIdsScopestringNo

The IDs of regions. Separate multiple IDs with commas (,).

cn-hangzhou,cn-shanghai
ExcludeRegionIdsScopestringNo

The IDs of regions to be excluded. Separate multiple IDs with commas (,).

cn-beijing,cn-guangzhou
ResourceIdsScopestringNo

The IDs of resources. Separate multiple IDs with commas (,).

i-2zee******ym49kfmwis,vpc-5ts6******fnw493g849a
ExcludeResourceIdsScopestringNo

The IDs of resources to be excluded. Separate multiple IDs with commas (,).

pc-uf6p******4h784y,rmq-cn-******ny0y
ResourceTypesScopestringNo

The resource types. Separate multiple resource types with commas (,).

rds.dbinstance,oss.bucket
ExcludeResourceTypesScopestringNo

The resource types to be excluded. Separate multiple resource types with commas (,).

mse.cluster,slb.loadbalancer

Example 1: Enable the system to automatically transfer resources based on tags

{
  "RuleName": "Custom Transfer Rule for Online Resources of Project A",
  "RuleDesc": "Transfer resources to which the {\"env\": \"online\"} and {\"project\": \"A\"} tags are added to the 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: Enable the system to automatically transfer resources together with an Elastic Compute Service (ECS) instance

{
  "RuleName": "Cloud Disk Transferred Together with ECS Instance",
  "RuleDesc": "When a cloud disk is attached to an ECS instance or the ECS instance is transferred from a resource group to another, the cloud disk is automatically transferred to the resource group to which the ECS instance belongs.",
  "RuleType": "associated_transfer",
  "ResourceTypesScope": "ecs.disk",
  "RuleContents": [
    {
      "TargetResourceGroupCondition": "{\"desired\":\"$.ResourceGroupId\",\"desiredSource\":\"RESOURCE_RELATIONSHIP_ACS::ECS::Instance\",\"featurePath\":\"$.ResourceGroupId\",\"featureSource\":\"CONFIGURATION\",\"operator\":\"StringEquals\"}"
    }
  ]
}

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

RequestIdstring

The request ID.

F7701451-340B-5CB3-AEA7-7D831F7F38C0
RuleIdstring

The ID of the rule.

gr-acfo******hy6a

Examples

Sample success responses

JSONformat

{
  "RequestId": "F7701451-340B-5CB3-AEA7-7D831F7F38C0",
  "RuleId": "gr-acfo******hy6a"
}

Error codes

HTTP status codeError codeError messageDescription
400Invalid.AssociatedTransferRule.AlreadyExistedThe associated transfer rule already exists.The associated transfer rule already exists.
400InvalidParameter.ResourceTypesScopeThe parameter ResourceTypesScope is invalid.The parameter ResourceTypesScope is invalid.
400InvalidParameter.ExcludeResourceTypesScopeThe parameter ExcludeResourceTypesScope is invalid.The parameter ExcludeResourceTypesScope is invalid.
400InvalidParameter.ResourceGroupIdsScopeThe parameter ResourceGroupIdsScope is invalid.The parameter ResourceGroupIdsScope is invalid.
400InvalidParameter.ExcludeResourceGroupIdsScopeThe parameter ExcludeResourceGroupIdsScope is invalid.The parameter ExcludeResourceGroupIdsScope is invalid.
400InvalidParameterCombination.BothRegionIdScopesThe 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.
400InvalidParameterCombination.BothResourceGroupIdScopesThe 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.
400InvalidParameterCombination.BothResourceIdScopesThe 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.
400InvalidParameterCombination.BothResourceTypeScopesThe 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.
400InvalidParameter.RuleContentsThe parameter RuleContents is invalid.The parameter RuleContents is invalid.
400MissingParameter.RuleContentsThe parameter RuleContents is required.The parameter RuleContents is required.
409AutoGroupingNotEnabledThe auto grouping is disabled.The auto grouping is disabled.
409QuotaExceeded.RuleContentThe number of rule contents exceeds the quota.The number of rule contents exceeds the quota.
409QuotaExceeded.GroupingRuleThe number of grouping rules exceeds the quota.The number of grouping rules exceeds the quota.

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