Search code examples
oracle-cloud-infrastructure

How to list untagged resources in Oracle Cloud tenant


How can you easily list all the untagged resources in a tenant? I tried the built in search capability, but looks like you can only search for specific tags and values.


Solution

  • Using the oci cli with the built in search capability I found the right command I need. In this example I used the owner tag withing the Monitoring namespace I created for tag defaults:

    oci search resource structured-search --profile <ProfileName> --region <RegionName> --query-text "QUERY instance resources" --query "data.items[?!(\"defined-tags\".Monitoring.owner)].{\"Instance Name\":\"display-name\", OCID:\"identifier\"}" --output table
    

    This will only list those compute resources, that do not have an owner tag (as it was created before tag defaults was introduced) or the owner tag is not set for any reason. This will help to find those resources, that need to be cleaned up in order to know the owner of each resource. Similar command has to be executed for other resource types though.