Professional Documents
Culture Documents
Ops CLI
Ops CLI
Ops CLI
Try this hands-on lab with the Oracle Cloud Free Tier. If you do not have a free
account, click here to get one.
Overview
In this practice, you create a VCN with one public subnet using OCI CLI.
Tasks
1. Log in to the OCI free tier account
2. SSH to the Public IP address of your Terraform Server created in the previous practice
using Cloud Shell.
$ ssh opc@<Public_IP_of_Compute>
5. Select View Configuration File and copy the contents of configuration file displayed.
Make a note of the security list ocid: for use in the next step.
10. Create a public subnet.
$ oci network subnet create --cidr-block 192.168.10.0/24 -c $cid -
-vcn-id <CLI Demo VCN OCID> --security-list-ids '["<security list
OCID from previous step>"]'
Record the subnet ocid after it is created. You will need it in an upcoming step.
11. Create an Internet Gateway. You will need the OCID of your VCN and Compartment.
$ oci network internet-gateway create -c $cid --is-enabled true --
vcn-id <CLI Demo VCN OCID> --display-name DemoIGW
Make a note of the id: for this resource after it has been created.
Overview
In this practice, you will retrieve the OCID for the latest Oracle Linux image, and then launch a
compute instance.
Tasks
1. Use the CLI query command to retrieve the OCID for the latest Oracle Linux image. Make a
note of the image ID for future use.
Important: Text in bold red font below is the Oracle Linux version you’re searching for. If
this search doesn’t return any result, please try searching for a higher version, such as the
default one that is displayed in the “Create Instance” form in the console.
$ oci compute image list --compartment-id $cid --query
'data[?contains("display-name",`Oracle-Linux-7.9-
20`)]|[0:1].["display-name",id]'
2. Launch a compute instance with the following command. We previously created a
regional subnet because our command did not include a specific availability domain. For
compute instances, we must specify an availability domain and a subnet.
You will need the following information:
Availability domain name (the first command gives this)
Subnet OCID
Valid compute shape (that is, VM.Standard.E2.1.Micro)
Your public SSH key
$ oci iam availability-domain list
$ oci compute instance launch --availability-domain <your AD
name> --display-name demo-instance --image-id <ID from previous
step> --subnet-id <previous practice subnet OCID> --shape
VM.Standard.E2.1.Micro --compartment-id $cid --assign-public-ip
true --metadata '{"ssh_authorized_keys": "<your public ssh key
here>"}'
Capture the id: of the compute instance launch output.
3. Check the status of the instances:
$ oci compute instance get --instance-id <the instance OCID> --
query 'data."lifecycle-state"'
Rerun the command every 30-60 seconds until the lifecycle state is RUNNING.