Skip to content

Instantly share code, notes, and snippets.

@EscVector
Last active June 3, 2020 07:42
Show Gist options
  • Save EscVector/282a8c9fa3d4c044919809ea060bd700 to your computer and use it in GitHub Desktop.
Save EscVector/282a8c9fa3d4c044919809ea060bd700 to your computer and use it in GitHub Desktop.
Oci Commands
## Query syntax
## http://jmespath.org/examples.html#filters-and-multiselect-lists
#list all tenancy ACTIVE compartments [name,ocid]
oci iam compartment list --all --output table --compartment-id-in-subtree true --query "data [?\"lifecycle-state\" =='ACTIVE'].{Name:name,OCID:id}"
#list all tenancy DELETED compartments [name,ocid]
oci iam compartment list --all --output table --compartment-id-in-subtree true --query "data [?\"lifecycle-state\" =='DELETED'].{Name:name,OCID:id}"
#image list
oci compute image list --output table --query "data[*]".{"ocid:id,name:\"display-name\""} --compartment-id $ocid
#Get OCID by Name Contains
oci compute instance list --query "data[?contains(\"display-name\",'kafka')]".{"ocid:id"} --compartment-id $ocid
#Get Public IP By Instance ID
oci compute instance list-vnics --query "data[*]"."{\"public-ip\":\"public-ip\"}" --instance-id $ocid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment