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
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 Resourcesis 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.
| Operation | Access level | Resource type | Condition key | Associated operation |
|---|---|---|---|---|
| resourcemanager:CreateAutoGroupingRule | create | *All Resources * |
| none |
Request parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| RuleName | string | Yes | The name of the rule. | Custom Transfer Rule for Online Resources of Project A |
| RuleDesc | string | No | 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. |
| RuleType | string | Yes | The type of the rule. Valid values:
| custom_condition |
| RuleContents | array<object> | Yes | The content records of the rule. | |
| object | Yes | The content record of the rule. | ||
| AutoGroupingScopeCondition | string | No | 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"} |
| TargetResourceGroupCondition | string | Yes | The condition for the destination resource group. | {"children":[{"desired":"rg-aek2********qcy","featurePath":"$.resourceGroupId","featureSource":"RESOURCE","operator":"StringEquals"}],"operator":"and"} |
| ResourceGroupIdsScope | string | No | The IDs of resource groups. Separate multiple IDs with commas (,). | rg-aekz******4b5ea,rg-aek2******fxykq |
| ExcludeResourceGroupIdsScope | string | No | The IDs of resource groups to be excluded. Separate multiple IDs with commas (,). | rg-aekz******zj2oi,rg-aekz******r62ua |
| RegionIdsScope | string | No | The IDs of regions. Separate multiple IDs with commas (,). | cn-hangzhou,cn-shanghai |
| ExcludeRegionIdsScope | string | No | The IDs of regions to be excluded. Separate multiple IDs with commas (,). | cn-beijing,cn-guangzhou |
| ResourceIdsScope | string | No | The IDs of resources. Separate multiple IDs with commas (,). | i-2zee******ym49kfmwis,vpc-5ts6******fnw493g849a |
| ExcludeResourceIdsScope | string | No | The IDs of resources to be excluded. Separate multiple IDs with commas (,). | pc-uf6p******4h784y,rmq-cn-******ny0y |
| ResourceTypesScope | string | No | The resource types. Separate multiple resource types with commas (,). | rds.dbinstance,oss.bucket |
| ExcludeResourceTypesScope | string | No | 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
Examples
Sample success responses
JSONformat
{
"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. |
For a list of error codes, visit the Service error codes.
