When you create resources in or add resources to a resource group, those resources automatically inherit specified tags from the group.
Background
For supported services, see the Support for automatic tag inheritance from a resource group column in Alibaba Cloud services that support tag policies.
Procedure
Both Current Account and resource directory tag policies support automatic tag inheritance from resource groups. The following example uses a Current Account tag policy to attach the tag env:test to a resource group. The env:test tag then automatically propagates to ECS instances in that group.
-
Add a tag to the resource group.
This example adds the tag
env:testto the resource group. Add a tag to a resource group. -
Enable the tag policy feature.
-
Create a tag policy.
-
On the Policy Library page, click Create Tag Policy.
-
Enter a Policy Name.
-
Enter a Policy Description.
-
Configure the policy in Quick Mode.
-
Set Policy Scenario to Automatically Inherit Tags for Resources from Resource Groups.
-
In the Tag Key field, enter
env. -
Select Specify Resource Types for Detection, and then specify all resource types for ECS.
By default, the policy detects all supported resource types. Select this option to limit detection to specific resource types.
-
Select Resource Groups, click Select Resource Group, and then select the resource group that you tagged in Step 1.
Note-
A Current Account tag policy applies to all resource groups by default. You can limit the scope to a maximum of 20 resource groups.
-
A resource directory tag policy applies to all resource groups by default. You cannot limit the scope to specific resource groups.
-
-
To exclude specific resources within the specified resource groups, select Specify IDs of Resources to Be Excluded, click Specify Resource IDs, and then enter the resource IDs to exclude.
NoteYou can enter a maximum of 20 resource IDs to exclude.
-
-
Click Create.
-
-
Attach the tag policy.
-
In the list of tag policies, find the policy you created in Step 3 and click Bind in the Actions column.
-
In the Bind dialog box, click OK.
The tag policy applies to the current Alibaba Cloud account and its RAM users.
-
-
After a short delay, verify that the tag policy has taken effect.
ECS instances in the resource group are automatically tagged with
env:test, which confirms the tag policy is in effect. Tags on the resource group that are not specified in the policy are not inherited.NoteA tag policy takes effect after a short delay described in Limitations.