Updated on 2024-03-13 GMT+08:00

Creating a Tag Policy

To standardize the usage of tags in your organization, you can create a tag policy to formulate rules for the tags.

You can create a tag policy from the organization administrator, but not from any delegated administrator.

Procedure

  1. Log in to Huawei Cloud as the organization administrator or using the management account, and navigate to the Organizations console.
  2. Access the Policies page, and click Tag policies.

    Figure 1 Accessing the Tag policies page

  3. Click Create Policy.

    Figure 2 Creating a tag policy

  4. Edit the policy name. The policy name is automatically generated when you create a policy. You can change the policy name if needed. Ensure that you are entering a unique policy name, different from any existing one.

    (Optional) You can also enter a description for the policy.

  5. Edit the policy content. Currently, you can edit the policy content using the visual editor or JSON.

    • Visual editor: When you use the visual editor to edit a policy, you do not need to understand the JSON syntax. After you edit in the visual editor, the new policy is automatically generated. The procedure is as follows:
      1. Enter the key for the tag you want to define in the tag policy.
      2. Use the capitalization you specified above for the tag key.

        If you select this option, the capitalization you specified for Tag Key is used for checking compliance. If you do not select this option, tag keys in all lowercase characters are considered compliant even if Tag Key contains uppercase characters. For example, when you enter CostCenter for Tag Key, if you select this option, CostCenter will be the standards for compliance check; if you do not select this option, costcenter will be the standards.

      3. Specify allowed values for this tag key.

        If you select this option and click Specify Values to specify one or more allowed values for the tag key, only those values you specified are considered compliant. If you do not select this option or you select this option but do not specify any values, any value (including no value at all) is considered compliant.

        Figure 3 Specifying allowed values for this tag key
      4. Specify resource types to enforce the tag policy.

        Select the Prevent noncompliant operations on this tag. option and click Specify Resource Types. In the displayed dialog box, read and confirm the effects of using tag policies. Then, select resource types and click OK.

        Figure 4 Specifying resource types
      5. Click Add Tag Key to add another tag key to this tag policy.
    • JSON: When using JSON syntax, you can edit the policy text by referring to Tag Policy Syntax. The system automatically verifies the syntax. If the syntax is incorrect, modify it as prompted.
      Figure 5 Editing a policy using JSON

  6. (Optional) Add one or more tags to the policy. Enter a tag key and a tag value, and click Add.

    Figure 6 Adding a tag

  7. Click Save in the lower right corner. If the tag policy is created successfully, it will be added to the list.