0

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.

1
  • I could list untagged compute instances with this oci cli command, but that only works for a single compartment: oci compute instance list -c ocid1.compartment.oc1..aaaaaaaa...a --query "data [?!(\"freeform-tags\")]|[?!(\"defined-tags\")].{InstanceName:\"display-name\", ocid:\"id\"}" --output table Similar command works for other resources. But still no solution for the complete tenant.
    – lsarecz
    Commented Jan 15, 2020 at 12:15

3 Answers 3

2

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.

0

can you try without -c ocid? I'm suggesting since you could get the list for specific compartment.

OCI search does not officially support this use case

1
  • Unfortunately compartment-id is a mandatory option of the list command, so doesn't work without that.
    – lsarecz
    Commented Jan 16, 2020 at 7:29
0

Search service do not list all resources : some services/resources are not intergrated with it.

If you really want to list all untagged resources in your tenant, I think you have no other choice to :

  • list all resources using each service command,
  • capture the API output,
  • filter for resources without tag.

Not the answer you're looking for? Browse other questions tagged or ask your own question.