Tag Management Features

This section describes the operations available to an administrator who sets up and manages tag namespaces and key definitions.

Retiring and Reactivating Tag Definitions

You can retire a tag key definition or a tag namespace definition.

When you retire a tag key definition, you can no longer apply it to resources. However, the tag is not removed from the resources that it was applied to. The tag still exists as metadata on those resources and you can still call the retired tag in operations such as searching, listing, sorting, or reporting.

You can reactivate retired tag key definitions and tag namespace definitions.

  • When you reactivate a tag key, it is again available for users to apply to resources.

  • When you reactivate a tag namespace, you can create new tag key definitions in that namespace. However, if you want to use any of the tag key definitions that were retired with the namespace, you must explicitly reactivate each tag key definition.

Moving Tag Namespaces

You can move a tag namespace to a different compartment. The tag namespace can be active or retired when you move it. When you move the tag namespace, all its tag key definitions are moved along with it.

This functionality is useful if you need to reorganize your compartment hierarchy, or if you need to delete a compartment that contains a retired tag namespace. Remember that you cannot delete a compartment that contains resources. A retired tag namespace, even though it is retired, is still an existing resource. Moving the retired tag namespace to a different compartment can enable you to delete its original containing compartment.

To move a tag namespace, you must be allowed to manage tag-namespaces in both compartments.

Deleting Tag Definitions

You can delete tag key definitions and tag namespaces.

When you delete a tag key definition, you begin a process that removes the tag from all resources in your tenancy. The delete action is asynchronous and initiates a work request. Once you start the delete operation, the state of the tag changes to deleting, and tag removal from resources begins. This process can take several hours depending on the number of resources that were tagged. When all tags have been removed, the state changes to deleted. You cannot restore a deleted tag. After the tag state changes to "deleted", you can use the same tag name again.

To delete a tag key definition, you must first retire it. To delete a tag namespace, you must first retire the tag namespace. When you retire a tag namespace that contains tag key definitions, all the tag keys in the namespace are retired, allowing you to delete the tag keys. The tag namespace can be deleted only after all its tag key definitions have been deleted.

Using Predefined Values

You can create a list of values and associate that list with a tag key definition. When users then apply the tag to a resource, they must select a value from the list of predefined values. Use lists of predefined values to impose limits on the values that users can apply to tags.

In the OCI CLI and Compute API, predefined values are specified through what is known as a validator. The validator is a parameter of a defined tag, used to supply the predefined values in JSON format. The Compute Web UI does not mention the term "validator", though it follows the same principle.

You can update existing tags to use predefined values. Every list of predefined values that you create must contain at least one value. Lists cannot contain duplicate values or blank entries. With predefined values, users applying tags cannot set the value of a tag to null.

You can use predefined values with defined tags and default tags. In combination with a default tag, users are required to select a tag value from the predefined list for each resource they create in the compartment where the default tag is used. This ensures that new resources contain metadata with values that you expect and can trust.

Using Tag Variables

You can use a variable to set the value of a defined tag. When users add the tag to a resource, the variable resolves to the data it represents. You can use tag variables in defined tags and default tags.

Consider the following example:

Operations.CostCenter="${iam.principal.name} at ${oci.datetime}"

Operations is the namespace, CostCenter is the tag key, and the tag value contains two tag variables ${iam.principal.name} and ${oci.datetime}. When you add this tag to a resource, the variables resolve to your user name – the name of the principal who applied the tag – and a time stamp for when you added the tag.

user-name at 2021-04-18T14:32:57.604Z

The variable is replaced with data at the moment the tag is applied to a given resource. If you later edit the tag, the variable is gone and only the data remains. You can edit the tag value in all the ways you would edit any other tag value.

To create a tag variable, you must use a specific format. The following tag variables are supported:

Variable Description

${iam.principal.name}

The name of the principal applying the tag to the resource.

${iam.principal.type}

The type of principal applying the tag to the resource.

${oci.datetime}

The date and time when the tag was created.