Resource Management provides the automatic tag inheritance feature. This feature allows resources that are added to or created in a resource group to automatically inherit the tags that are added to the resource group.
Background information
For information about Alibaba Cloud services that support the automatic tag inheritance feature, see the Support for automatic tag inheritance from a resource group column in Services that support tag policies.
Procedure
This example shows how to enable Elastic Compute Service (ECS) instances in a resource group to automatically inherit the tag env:test
that is added to the resource group.
Add a tag to a resource group.
In this example, the tag env:test is used. For more information, see Add a tag to a resource group.
Enable the Tag Policy feature.
For more information, see Enable the Tag Policy feature.
Create a tag policy.
Go to the Current Account tab of the Policy Library page in the Resource Management console and click Create Tag Policy.
On the Create Tag Policy page, enter a policy name in the Policy Name field.
Enter a description for the tag policy in the Policy Description field.
Configure the tag policy on the Quick Mode tab.
Enter
env
in the Tag Key field.Select Automatically Inherit Tags for Resources from Resource Groups for Select Policy Scenario.
Select Specify the detected resource type for this tag key and click Specify Resource Types. In the dialog box that appears, select all resource types of ECS.
By default, the tag policy detects resources of all resource types that are supported. If you select a specific resource type, the tag policy detects only the resources of the selected resource type.
Select Specify Resource Groups and click Select Resource Groups. In the Specify Resource Groups dialog box, select the resource group that is used in Step 1 and click OK.
NoteBy default, a tag policy in single-account mode takes effect for all resource groups. However, you can specify the resource groups for which you want the tag policy to take effect. You can specify a maximum of 20 resource groups.
By default, a tag policy in resource directory mode takes effect for all resource groups. You cannot specify the resource groups for which you want the tag policy to take effect.
If you do not want some resources in the resource group to inherit the tag, select Specify IDs of Resources to Be Excluded and click Specify Resource IDs. In the Specify IDs of Resources to Be Excluded dialog box, enter the resource IDs that you want to exclude. Then, click OK.
NoteYou can specify a maximum of 20 resource IDs that you want to exclude.
Click Create.
Attach the tag policy.
Go to the Current Account tab of the Policy Library page, find the tag policy created in Step 3 and click Attach in the Actions column.
In the Attach message, click OK.
The tag policy takes effect for the current Alibaba Cloud account and RAM users within the account.
Check whether the tag policy is in effect.
If the tag
env:test
is automatically added to the ECS instances in the resource group, the tag policy is in effect. If other tags are added to the resource group but the tags are not defined in the tag policy, the ECS instances in the resource group do not automatically inherit the tags.NoteYou must wait a period of time before a tag policy that is attached to an object takes effect. For information about the time that is required, see Limits in Overview.