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

  1. Log into the OCI Console
  2. Go to Identity > Users
  3. Click your username
  4. Open the API Keys tab
  5. 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 and oci network subnet create
    • However, the Console is quicker for one-time setup

πŸš€ 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.