DEV Community

Ryan Tiffany
Ryan Tiffany

Posted on

Getting Started with IBM Cloud CLI Search

Overview

This guide will show you how to get started using the IBM Cloud CLI resource search function to locate resources on your account.

The examples are divided in to two sections:

  • Cloud = IBM Cloud Resources.
  • IaaS = Classic Infrastructure (SoftLayer) Resources.

If you do not have the IBM Cloud CLI installed you can refer to this doc for installation instructions. Alternately you can use IBM Cloud Shell which has all of the tools we will need out of the box.

Search Cloud Resources (Cloud)

$ ibmcloud resource search 'name:devcluster'
Enter fullscreen mode Exit fullscreen mode

Search by resource name and return CRN (Cloud)

$ ibmcloud resource search 'name:devcluster' --output json | jq -r '.items[].crn'
Enter fullscreen mode Exit fullscreen mode

Search by resource tag (Cloud)

$ ibmcloud resource search 'tags:ryantiffany' --output json
Enter fullscreen mode Exit fullscreen mode

Return resource names (Cloud)

$ ibmcloud resource search 'tags:ryantiffany' --output json | jq -r '.items[].name'
Enter fullscreen mode Exit fullscreen mode

Return resource CRNs (Cloud)

$ ibmcloud resource search 'tags:ryantiffany' --output json | jq -r  '.items[].crn'
Enter fullscreen mode Exit fullscreen mode

Return resource types (Cloud)

$ ibmcloud resource search 'tags:ryantiffany' --output json | jq -r  '.items[].type'
Enter fullscreen mode Exit fullscreen mode

Search classic infrastructure (IaaS)

$ ibmcloud resource search -p classic-infrastructure --output json
Enter fullscreen mode Exit fullscreen mode

Search classic infrastructure by tag (IaaS)

$ ibmcloud resource search "tagReferences.tag.name:ryantiffany" -p classic-infrastructure --output json
Enter fullscreen mode Exit fullscreen mode

Return resource types (IaaS)

$ ibmcloud resource search "tagReferences.tag.name:ryantiffany" -p classic-infrastructure --output json | jq -r '.items[].resourceType'
Enter fullscreen mode Exit fullscreen mode

Search by tag and filter on virtual instances (IaaS)

$ ibmcloud resource search "tagReferences.tag.name:ryantiffany _objectType:SoftLayer_Virtual_Guest" -p classic-infrastructure --output json 
Enter fullscreen mode Exit fullscreen mode

Search IaaS Virtual instances by Tag and return FQDNs

$ ibmcloud resource search "tagReferences.tag.name:ryantiffany _objectType:SoftLayer_Virtual_Guest" -p classic-infrastructure --output json | jq -r '.items[].resource.fullyQualifiedDomainName'
Enter fullscreen mode Exit fullscreen mode

Search IaaS Virtual instances by Tag and return instance ID's


shell
$ ibmcloud resource search "tagReferences.tag.name:<tag> 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)