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.


Visual Overview:

graph LR
    subgraph "CI/CD Pipeline"
        Code[Code Commit] --> Build[Build]
        Build --> Test[Test]
        Test --> Security[Security Scan]
        Security --> Deploy[Deploy]
        Deploy --> Monitor[Monitor]
    end

    style Code fill:#667eea,color:#fff
    style Security fill:#f44336,color:#fff
    style Deploy fill:#4caf50,color:#fff

๐Ÿ”ง 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.