How to Provision a VM on OCI with Flexible Shape

OCI has a lot of shapes to choose from. What is a Shape? Here is a quote from the official site.

A shape is a template that determines the number of CPUs, amount of memory, and other resources that are allocated to an instance.

So what if you cannot find the shape you would like to use? It is possible to use this VM.Standard.E3.Flex shape and specify the size of the memory and CPUs. Here is an example I am using to spin up a proxy server in Tokyo.

resource oci_core_instance tokyo-proxy {
    compartment_id      = var.tenancy_ocid
    display_name        = "tokyo-proxy"
    availability_domain = "GUMM:AP-TOKYO-1-AD-1"
    shape               = "VM.Standard.E3.Flex"

    shape_config {
        memory_in_gbs = 2
        ocpus = 1
    }
    
    source_details {
        source_type = "image"
        source_id   = var.config["image_ocid"]
        boot_volume_size_in_gbs = 50
    }
    create_vnic_details {
        assign_public_ip = "true"
        hostname_label   = "tokyo-proxy"
        subnet_id        = var.config["public_subnet_ocid"]
    }
    metadata = {
        ssh_authorized_keys = file(var.public_ssh_key)
    }
}

This provisions quite a small instance in ap-tokyo-1 region, which I am planning to use as a proxy server to watch movies from Japan. Even a smaller spec would do but I will go with it for the time being.

I believe the boot volume size cannot be lower than 50 GB. You can read the official documentation regarding the minimum boot volume size.