Creating and Managing Tag Namespaces

Tag namespaces enable you to create collections of related tags. After you create a tag namespace, create tag key definitions within that tag namespace. See Creating and Managing Tag Key Definitions. Tag namespaces with tag key definitions must exist in the tenancy before users can apply a defined tag to a resource.

Creating a Tag Namespace

A tenancy can have at most 100 tag namespaces.

Using the Compute Web UI

  1. In the navigation menu, click Governance, and then click Tag Namespaces.

  2. Above the list of tag namespaces, click the Create Namespace Definitions button.

  3. In the Create Namespace Definition window, enter the following information:

    • Create in Compartment: The compartment in which you want to create the namespace definition.

    • Namespace Definition Name: A name for this tag namespace. Tag namespace names have the following characteristics:

      • Must be unique within the tenancy.

        Do not use the name OraclePCA. The OraclePCA namespace is a reserved namespace.

      • Are case insensitive.

      • Cannot be changed later.

      • Can be no more than 100 characters.

      • Cannot contain period (.) or space characters.

    • Description: A description for this set of tags. This description can be no more than 256 characters.

    • Tagging: (Optional) Add defined or free-form tags for this tag namespace as described in Adding Tags at Resource Creation. Tags can also be applied later.

  4. Click Create Namespace Definition.

    The new tag namespace definition is displayed on the Tag Namespaces page.

Using the OCI CLI

  1. Get the OCID of the compartment where you want to create the tag namespace.

    $ oci iam compartment list --compartment-id-in-subtree true
  2. Run the tag namespace create command.

    Syntax:

    oci iam tag-namespace create --compartment-id compartment_OCID --name tag_namespace_name \
    --description "text"

    Do not use the name OraclePCA. The OraclePCA namespace is a reserved namespace.

    Use the following command to verify that the name you want to use is unique in the tenancy:

    $ oci iam tag-namespace list --compartment-id tenancy_OCID

    You can tag the new tag namespace during creation by adding the options described in Adding Tags at Resource Creation.

    Example:

    $ oci iam tag-namespace create --compartment-id ocid1.compartment.unique_ID --name Products \
    --description "Identify resources used in product development."

    This command returns the same output as the tag-namespace get command.

Updating a Tag Namespace

Do not try to update the OraclePCA tag namespace. The OraclePCA namespace is a reserved namespace. You cannot modify tags in the OraclePCA namespace or add your own tags in that namespace.

Using the Compute Web UI

  1. In the navigation menu, click Governance, and then click Tag Namespaces.

  2. If the tag namespace that you want to modify is not listed, use the Compartment drop-down menu above the tag namespaces list to select the correct compartment.

  3. For the namespace that you want to modify, click the Actions menu, and click the Edit option.

    The Edit dialog is displayed.

  4. Update the tag namespace.

    You can modify the description of a tag namespace and add or modify tags on the tag namespace.

  5. Click Update Tag Namespace.

Using the OCI CLI

  1. Get the tag namespace OCID.

    $ oci iam tag-namespace list --compartment-id compartment_OCID
  2. Run the tag namespace update command.

    Syntax:

    oci iam tag-namespace update --tag-namespace-id tag_namespace_OCID --description "text"

    To add or modify a tag on the tag namespace, add the options described in Applying Tags to an Existing Resource.

    Example:

    $ oci iam tag-namespace update --tag-namespace-id ocid1.tagnamespace.unique_ID \
    --description "Identify resources used to develop different products."

    This command returns the same output as the tag-namespace get command.

Retiring a Tag Namespace

When you retire a tag namespace, all tag key definitions and tags in that tag namespace are retired, and you cannot create new tag key definitions in that tag namespace. Retired tags cannot be applied to resources. However, retired tags remain applied to any resources where they were already applied and can still be used in operations such as listing, sorting, and filtering.

Using the Compute Web UI

  1. In the navigation menu, click Governance, and then click Tag Namespaces.

  2. If the tag namespace that you want to retire is not listed, use the Compartment drop-down menu above the tag namespaces list to select the correct compartment.

  3. For the tag namespace that you want to retire, click the Actions menu, and click the Retire option.

  4. At the Retire Tag Namespace confirmation prompt, click Confirm.

    The state of the tag namespace changes to Inactive. On the details page for the tag namespace, the tag key definitions are also in state Inactive.

Using the OCI CLI

  1. Get the tag namespace OCID.

    $ oci iam tag-namespace list --compartment-id compartment_OCID
  2. Run the tag namespace retire command.

    Syntax:

    oci iam tag-namespace retire --tag-namespace-id tag_namespace_OCID

    This command returns the same output as the tag-namespace get command.

Reactivating a Tag Namespace

You can reactivate a tag namespace that is retired. When you reactivate a tag namespace, you can create new tag key definitions in that tag namespace.

When you reactivate a retired tag namespace, the tag key definitions and tags are not reactivated. To use tag key definitions that were retired with the namespace, you must explicitly reactivate each tag key definition.

Using the Compute Web UI

  1. In the navigation menu, click Governance, and then click Tag Namespaces.

  2. If the tag namespace that you want to reactivate is not listed, use the Compartment drop-down menu above the tag namespaces list to select the correct compartment.

  3. For the tag namespace that you want to reactivate, click the Actions menu, and click the Reactivate option.

  4. At the Reactivate Tag Namespace confirmation prompt, click Confirm.

    The state of the tag namespace changes to Active. On the details page for the tag namespace, the tag key definitions are still shown as Inactive.

Using the OCI CLI

  1. Get the tag namespace OCID.

    $ oci iam tag-namespace list --compartment-id compartment_OCID
  2. Run the tag namespace reactivate command.

    Syntax:

    oci iam tag-namespace reactivate --tag-namespace-id tag_namespace_OCID

    This command returns the same output as the tag-namespace get command.

Moving a Tag Namespace to a Different Compartment

You can move an active or retired tag namespace and its tag key definitions to a different compartment within the same tenancy.

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

To move a tag namespace, you must use the OCI CLI.

Using the OCI CLI

  1. Get the following information:

    • The OCID of the compartment where you want to move the tag namespace.

      $ oci iam compartment list --compartment-id-in-subtree true
    • The tag namespace OCID.

      $ oci iam tag-namespace list --compartment-id compartment_OCID
  2. Run the tag namespace move command.

    Syntax:

    oci iam tag-namespace change-compartment --compartment-id destination_compartment_OCID \
    --tag-namespace-id tag_namespace_OCID

    Use the tag-namespace get command to verify the new compartment-id.

Deleting a Tag Namespace

A tag namespace must be retired before it can be deleted. See Retiring a Tag Namespace.

To delete a tag namespace, all tag key definitions in that namespace must be deleted. See Deleting a Tag Key Definition.

Using the Compute Web UI

  1. In the navigation menu, click Governance, and then click Tag Namespaces.

  2. If the tag namespace that you want to delete is not listed, use the Compartment drop-down menu above the tag namespaces list to select the correct compartment.

  3. Ensure that the tag namespace that you want to delete is retired (in state Inactive).

  4. Click the name of the tag namespace that you want to delete.

  5. In the Resources box on the tag namespace details page, click Tag Key Definitions.

  6. Ensure that all tag key definitions are deleted.

  7. On the Controls menu at the top of the details page, click the Delete option.

  8. At the Delete Tag Namespace confirmation prompt, click Confirm.

    The tag namespace is removed from the Tag Namespace list, and tags in that tag namespace are removed from resources.

Using the OCI CLI

  1. Get the tag namespace OCID.

    $ oci iam tag-namespace list --compartment-id compartment_OCID
  2. Ensure that the tag namespace that you want to delete is retired (in state Inactive).

    $ oci iam tag-namespace get --tag-namespace-id tag_namespace_OCID
  3. Ensure that all tag key definitions for this tag namespace are deleted.

    $ oci iam tag list --tag-namespace-id tag_namespace_OCID
  4. Run the tag namespace delete command.

    Syntax:

    oci iam tag-namespace delete --tag-namespace-id tag_namespace_OCID

    Example:

    $ oci iam tag-namespace delete --tag-namespace-id ocid1.tagnamespace.unique_ID
    Are you sure you want to delete this resource? [y/N]: y
    {
      "opc-work-request-id": "ocid1.workrequest.unique_ID"
    }

    Use the following command to check the status of the tag namespace delete:

    $ oci iam tagging-work-request get --work-request-id ocid1.workrequest.unique_ID

    To delete a tag namespace without confirmation, use the --force option.