Subnet Queries

Summary

Before creating a compute instance, I need to know what subnets are available.

References

Find Subnets

Run the following commands to find what subnets are available in the Sandbox compartment:

export sandbox_comp_id=$(   \
  oci iam compartment list  \
    --name 'Sandbox'        \
    --query 'data[0].id'    \
    --raw-output
  )
oci network subnet list                                                                 \
  --compartment-id ${sandbox_comp_id}                                                   \
  --query 'data[*].{OCID: id, "CIDR Block":"cidr-block", "Subnet Name":"display-name"}' \
  --output table                                                                        \

Sample output is:

+-------------+-------------------------------------------------------------------------------------------+----------------------------+
| CIDR Block  | OCID                                                                                      | Subnet Name                |
+-------------+-------------------------------------------------------------------------------------------+----------------------------+
| 10.0.3.0/24 | ocid1.subnet.oc1.ap-sydney-1.aaaaaaaayzpr5xhc4uid5wagusokwaczibbvoftfe4fyj7evdnbk524g6hla | example_subnet             |
| 10.0.1.0/24 | ocid1.subnet.oc1.ap-sydney-1.aaaaaaaabfb6tyssv2t4dxci5mhymomqmrhwdq2nmagdtezfp4ifmbca7c5q | public subnet-sandbox-vcn  |
| 10.0.2.0/24 | ocid1.subnet.oc1.ap-sydney-1.aaaaaaaa4khgvhu5dukjpsghgj2adw4pp23qnayfg272erjd33onwguvfr2q | private subnet-sandbox-vcn |
+-------------+-------------------------------------------------------------------------------------------+----------------------------+

Run the following commands to return all data about subnets that are available in the Sandbox compartment:

export sandbox_comp_id=$(   \
  oci iam compartment list  \
    --name 'Sandbox'        \
    --query 'data[0].id'    \
    --raw-output
  )
oci network subnet list               \
  --compartment-id ${sandbox_comp_id} \
  >subnet-queries.json

The full output has been uploaded as subnet-queries.json.