Skip to content

oci search resource PrivateIp lacks hostname/DNS label searchable attribute. #1062

Open

Description

@dmitry-shiryaev

oci search resource-type get --name PrivateIp shows that PrivateIp lacks any option to search that resource type (via oci search resource structured-search) using OCI assigned DNS/hostname labels. Is there a reasons for the lack of this searchable attribute, or is it just an oversight?

Commands such as oci network private-ip list --subnet-id return JSON objects with hostname-label attribute, so it seems that OCI internal representation of PrivateIp object has this info.

UPD.
Also, vnic-attachment resource is missing from oci search resources. It would be convenient to have that resource type as part of oci search, not just as oci compute vnic-attachment

Activity

  1. dmitry-shiryaev commented on Apr 8, 2026

    @dmitry-shiryaev
    Author

    Did a bit of digging.
    https://docs.oracle.com/en-us/iaas/Content/Search/Concepts/queryoverview.htm
    states privateIp as one of the supported resources. And the object reference of privateIp https://docs.oracle.com/en-us/iaas/api/#/en/iaas/20160918/PrivateIp states hostnameLabel as one of its attributes.
    but when I try using oci cli search by hostnameLabel I get this:

    oci --profile $OCI_CLI_PROFILE search resource structured-search --query-text "query privateIp resources where (hostnameLabel=='vm03')"                                                                   
    ServiceError:
    {
        "client_version": "Oracle-PythonSDK/2.168.1, Oracle-PythonCLI/3.76.0",
        "code": "CannotParseRequest",
        "logging_tips": "Please run the OCI CLI command using --debug flag to find more debug information.",
        "message": "Unknown field 'hostnamelabel' for resource type 'privateip'",
        "opc-request-id": "095A9B4352E0487280E632C9E26C3F99/0485FDD68D120D7CFEB0D5694652414A/920138AFC8951D4C161AA714F1516821",
        "operation_name": "search_resources",
        "request_endpoint": "POST https://query..oci.oraclecloud.com/20180409/resources",
        "status": 400,
        "target_service": "resource_search",
        "timestamp": "2026-04-08T01:35:58.446792+00:00",
        "troubleshooting_tips": "See [https://docs.oracle.com/iaas/Content/API/References/apierrors.htm] for more information about resolving this error. If you are unable to resolve this issue, run this CLI command with --debug option and contact Oracle support and provide them the full error message."
    }
    
  2. PechimuthuMithil commented on May 13, 2026

    @PechimuthuMithil
    Member

    Hello @dmitry-shiryaev !
    oci search is a client for OCI Resource Search, so the set of searchable resource types and searchable attributes comes from the Resource Search service/index. I believe that hostnamelabel is not supported in the current search index that is maintained. And as you have pointed out, it might also be that VnicAttachment is not a valid resource type in that index.
    I will try to convey this request to the OCI resource Search service team, meanwhile, can you try using a workaround with --query like so?

    oci network private-ip list --subnet-id <subnet_ocid> --all --query "data[?\"hostname-label\"=='<hostname_label>']"

    Thank you!

  3. dmitry-shiryaev commented on May 15, 2026

    @dmitry-shiryaev
    Author

    Thanks for your input @PechimuthuMithil

    oci search is a client for OCI Resource Search, so the set of searchable resource types and searchable attributes comes from the Resource Search service/index. I believe that hostnamelabel is not supported in the current search index that is maintained.

    In official OCI documentation for Search, there is a list of supported resources:
    https://docs.oracle.com/en-us/iaas/Content/Search/Concepts/queryoverview.htm#resourcetypes
    There is a PrivateIp resource in that list, with the link to the resource's attributes reference:
    https://docs.oracle.com/en-us/iaas/api/#/en/iaas/20160918/PrivateIp
    hostnameLabel is among those attributes, however is is not a searchable resource for CLI's oci search.

    And as you have pointed out, it might also be that VnicAttachment is not a valid resource type in that index.

    Indeed, VnicAttachment is not in the list. However it is an entity within OCI, so it would be handy to make it a searchable resource with Search.

    can you try using a workaround with --query like so?
    oci network private-ip list --subnet-id <subnet_ocid> --all --query "data[?"hostname-label"=='<hostname_label>']"

    I am writing a bash script to use OCI Bastion service to connect to Compute Instances in private sublet. oci bastion command to create ssh session needs:

    • Private IP (I want to use hostnames instead, but as you pointed out I can go from hostname label to private IP)
    • Compute Instance OCID, which is impossible to obtain knowing hostname label or private ip

    Private ip is assigned to VNIC, and the only thing that ties VNIC with Compute Instance is VNIC Attachment. And those aren't searchable. Ideally, I would like to be able to find private ip from hostname label, get OCID of VNIC this ip is attached to, then search VNIC Attachment by VNIC's OCID, then get OCID of the Compute Instance.

    Maybe there is an easier way, but I wasn't able to come up with anything. TLDR: I need private IP and Instace's OCID this IP is assigned to, knowing only OCI assigned hostname/dns label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions