Summary
References
Find All Availability Domains
The data returned by the oci iam availability-domain list
command can be returned in either tabular or JSON format. The tabular format is easier to scan, while the JSON can return all fields:
Create Table of All Available Domains
To find all availability domains in your tenancy, run the following command to return the output as a table:
oci iam availability-domain list \ --query 'data[*].{"AD Name":name, OCID:id}' \ --output table
Sample output is:
+-----------------------+--------------------------------------------------------------------------------------------+ | AD Name | OCID | +-----------------------+--------------------------------------------------------------------------------------------+ | bPBR:AP-SYDNEY-1-AD-1 | ocid1.availabilitydomain.oc1..aaaaaaaalhnzffyixz4hyhp7gtcdskahy22cekpcgndvwdjffrdv6d5iqi5a | +-----------------------+--------------------------------------------------------------------------------------------+
Create JSON File of All Availability Domains
To return all available data on availability domains in the tenancy into a JSON file, run the following command:
oci iam availability-domain list >all-availability-domain.json
The sample output is uploaded as all-availability-domain.json.
Get First AD OCID
To get the OCID of the first available AD (Availability Domain), use the following command:
export OCI_AD_OCID=$( \ oci iam availability-domain list \ --query 'data[0].id' \ --raw-output \ )
Get First AD Name
To get the name of the first available AD (Availability Domain), use the following command:
export OCI_AD_NAME=$( \ oci iam availability-domain list \ --query 'data[0].name' \ --raw-output \ )