Oracle Cloud Infrastructure (OCI) offers an always-free tier that includes ARM-based virtual machines (VM.Standard.A1.Flex). However, due to limited regional capacity, launching Free Tier instances through the web console often results in failure. Each failure forces you to manually reselect configurations β a time-consuming process. In contrast, the CLI lets you retry instantly with a single command, making it the preferred method when capacity is scarce.
π§ Step 1: Install OCI CLI
On macOS with Homebrew:
brew update && brew install oci-cli
For other operating systems, refer to Oracleβs official installation guide.
π Step 2: Run oci setup config
to Generate Credentials
oci setup config
The CLI will prompt for:
- Tenancy OCID
- User OCID
- Region
- Path to save your config file (default:
~/.oci/config
)
During setup, the tool also generates:
- A private key (
oci_api_key.pem
) - A public key (
oci_api_key_public.pem
)
Keep the private key secure. Youβll need to upload the public key in the OCI Console.
ποΈ Step 3: Upload Your Public Key in OCI Console
- Log into the OCI Console
- Go to Identity > Users
- Click your username
- Open the API Keys tab
- Click Add API Key and upload
oci_api_key_public.pem
This step authorizes CLI-based actions for your user.
π Step 4: Locate Required OCIDs
To launch a VM, gather the following OCIDs. You can find them using the Console or CLI:
-
Tenancy OCID: Console β Profile menu β Tenancy: [your tenancy name]
-
User OCID: Console β Profile menu β User Settings
-
Compartment OCID:
oci iam compartment list --compartment-id <TENANCY_OCID>
-
Availability Domain:
oci iam availability-domain list --compartment-id <COMPARTMENT_OCID>
-
Image OCID:
oci compute image list --compartment-id <COMPARTMENT_OCID>
Look for an Ubuntu or Oracle Linux image that supports A1 shape.
-
Subnet OCID:
oci network subnet list --compartment-id <COMPARTMENT_OCID>
β οΈ Replace actual OCIDs with placeholders like
<COMPARTMENT_OCID>
in your scripts. Never share your real OCIDs online.
π If You Donβt Have a Subnet
To launch an instance, a subnet is required. If you havenβt already created one:
-
Option 1: Use the OCI Console
- Go to Networking > Virtual Cloud Networks (VCNs)
- Create a VCN with Internet Connectivity
- This automatically creates a subnet
-
Option 2: Use the CLI
- Advanced users can use
oci network vcn create
andoci network subnet create
- However, the Console is quicker for one-time setup
- Advanced users can use
π Step 5: Launch a Free Tier VM Instance via CLI
The most common Free Tier eligible shape is:
VM.Standard.A1.Flex
with 1 OCPU and 6 GB RAM
Launch it with:
oci compute instance launch \
--compartment-id <COMPARTMENT_OCID> \
--availability-domain <AD_NAME> \
--shape VM.Standard.A1.Flex \
--image-id <IMAGE_OCID> \
--subnet-id <SUBNET_OCID> \
--assign-public-ip true \
--display-name "MyFreeTierVM" \
--shape-config '{"ocpus": 1, "memoryInGBs": 6}'
If capacity is unavailable in one AD, simply change --availability-domain
and retry.
π‘ Why CLI is Better for Free Tier Instances
- The web console requires manual input every attempt β dropdowns, forms, validations.
- If capacity is full, you must re-enter everything to try again.
- The CLI saves time β retry with a single command.
- Ideal for scripting and automation.
- Youβll know immediately whether a region has capacity, without wasting time clicking through forms.
β Summary
The OCI CLI helps you:
- π Install in minutes
- π Set up secure API access
- π Retrieve required OCIDs
- βοΈ Create or find your subnet and VCN
- β‘ Launch Free Tier instances quickly
- π Avoid repeated manual configuration in the UI
When time matters and capacity is tight, CLI is the smartest and fastest way to get started with Oracle Cloud Free Tier.