All Products
Search
Document Center

Resource Management:CreateAutoGroupingRule

Last Updated:Aug 31, 2026

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

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: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:

  • custom_condition: custom transfer rule.

  • associated_transfer: attached-resource transfer rule.

Valid values:

  • associated_transfer :

    Attached-resource transfer rule.

  • custom_condition :

    Custom transfer rule.

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.