All Products
Search
Document Center

Resource Management:Validate the letter casing and use of spaces in tag keys and values

Last Updated:Jan 04, 2026

You can use a case and space detection tag policy to validate the capitalization and spacing of tags on resources in your Alibaba Cloud account or resource directory. This feature automatically identifies tags that do not conform to your standards, helping you maintain consistent tags.

Prerequisites

  • The tag policy feature is enabled. For more information, see Enable the tag policy feature.

  • The AliyunTagAdministratorAccess policy is attached to the Resource Access Management (RAM) user that you use to perform the steps in this topic.

Supported Alibaba Cloud services

For a list of Alibaba Cloud services that support automatic tag detection, see the Support for automatic tag detection and remediation column in the "Services that support tag policies" section.

Detection rules

  1. Similar tag detection

    If two tags have the same key and value after leading and trailing spaces are removed and case is ignored, they are considered similar tags. For example, "Env":"Prod" and " env ":" prOd" are similar tags. However, "Env":"Prod" and "Env":"Pro d" are not similar tags because spaces in the middle of a value are not ignored.

    Note

    The similar tag definition is used for evaluation purposes. The final compliance report categorizes resources only as compliant, non-compliant, or not applicable.

  2. Compliance evaluation

    • Compliant: A resource is considered compliant if its tag key and value exactly match the standards that are defined in the policy. This includes the correct case and no leading or trailing spaces.

    • Non-compliant: A resource is considered non-compliant if it has a similar tag, but the tag key and value do not exactly match the standards that are defined in the policy.

    • Not applicable: A resource is considered not applicable if it does not have any similar tags.

For example, assume you define a standard tag key as Env with allowed values of Prod or Test. In this case:

  • Resource A with the tag "Env":"Prod"Compliant

  • Resource B with the tag "Env":"Test"Compliant

  • Resource C with the tag "Env":"prod"Non-compliant

  • Resource D with the tag " env ":"prod "Non-compliant

  • Resource E with the tag "dep":"a"Not applicable

  • Resource F with the tag "Env":"Pro d"Not applicable

Procedure

This example demonstrates how to create a tag policy that detects non-compliant tags on resources within the current account. For this example, the policy defines the standard tag key as Env with the allowed value Prod. The policy will then find non-compliant tags, such as "env:Prod", "Env:proD", or "Env":" Prod", because they have incorrect capitalization or include extraneous spaces.

Step 1: Create a tag policy

  1. Log on to the Resource Management console.

  2. In the left-side navigation pane, choose Tag Policy > Policy Library.

  3. On the Policy Library page, click the Policy Library tab and then the Current Account subtab. Then, click Create Tag Policy.

  4. On the Create Tag Policy page, configure the parameters.

    1. Set the Policy Name and Policy Description field.

    2. In the Details section, click the Quick Mode tab.

    3. In the Add Policy Scenario and Tag Key section, select Case and Space Detection.

    4. Enter Env in the Tag Key field.

    5. Enter Prod in the Specify Allowed Tag Values field.

  5. Click Create.

Step 2: Attach the tag policy

Attach the tag policy that you created in Step 1 to the current account. After the policy is attached, it becomes effective and starts evaluating resources in the account.

  1. On the Policy Library page, click the Policy Library tab and then the Current Account subtab. Find the policy that you just created in the policy list.

  2. Click Attach in the Actions column.

  3. In the Attach dialog box, click Attach. The tag policy is attached to the Alibaba Cloud account that you use for logon.

(Optional) Step 3: View the effective policy

When multiple policies are attached to the same account, they are aggregated into a single effective policy. For more information, see View an effective policy.

Step 4: View and download the non-compliance report

After the detection task runs, you can view the compliance report.

The report lists all detected non-compliant resources and is available for viewing in the console or for download.

  1. In the left-side navigation pane, choose Tag Policy > Effective Policies.

  2. Click the Current Account tab.

  3. Click the tag key Env or click Details in the Actions column to open the policy details page.

    • On the Detection Results tab, view the compliance status of your resources.

      image

    • In the Non-compliance Reports section, you can generate and download a report of detected non-compliant resources in Excel format.

      image

What to do next

You can correct the tags on non-compliant resources manually, or configure a policy to remediate them automatically. For information about how to use a tag policy to perform automatic tag remediation, see Enable automatic tag remediation.

After the remediation is complete, you can view the detection results again to verify the changes.