Useful OCI CLI recipes | Part two


Part two, see part one here

OBTAIN COMPARTMENT OCID FROM COMPARTMENT NAME

NOTE: Compartment names are case sensitive!!!

compname="xplrDEV"
compocid=$(oci iam compartment list --compartment-id-in-subtree true --all | jq --arg compname "$compname" '.data[] | select(."name"==$compname)' | jq -r ."id")
echo $compocid

OBTAIN FN-OCID FROM COMPARTMENT OCID + APP-NAME + FN-NAME

compartment="ocid1.compartment.oc1......aea" # use recipe above to obtain the ocid
appname="func-g-pt-dv"
fnname="nrch-fn"
appid=$(oci fn application list -c $compartment  --all | jq --arg appname "$appname" '.data[] | select(."display-name"==$appname)' | jq -r ."id")
fnid=$(oci fn function list --application-id $appid | jq --arg fnname "$fnname" '.data[] | select(."display-name"==$fnname)' | jq -r ."id")
echo $fnid

Hope it helps! 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.