This is a Terraform configuration that creates the Always Free instance on Oracle Cloud Infrastructure. By default, instance will have 4 Arm-based Ampere A1 cores, 24 GB of memory and 200 GB volume size.
In order to use Oracle Cloud Free Tier, you'll need to register free tier account. Once you have that set up, you can proceed with configuring auth.
Generate API key pair that will be used by provider.
mkdir ~/.oci
openssl genrsa -out ~/.oci/oci.pem 4096
openssl rsa -pubout -in ~/.oci/oci.pem -out ~/.oci/oci_public.pem
Go to Profile >> My profile >> API keys
and Add API key
. Paste public key and copy configuration preview file. Save configuration file as terraform.tfvars
in repository root.
Generate RSA key pair that will be used to SSH into instance.
For more details, check docs.
ssh-keygen -t ed25519 -C oci -f ~/.ssh/oci_free
Create bucket named tfstate
and get namespace. Save home region and endpoint details in backend.conf
file.
region = "<home region>"
endpoints = { s3 = "https://<namespace>.compat.objectstorage.<home region>.oraclecloud.com" }
For more details, check docs.
Go to Profile >> My profile >> Customer secret keys
and Generate secret key
. Create Customer Secret key and save access key and secret key in credentials
file.
[default]
aws_access_key_id=...
aws_secret_access_key=...
terraform init -backend-config=backend.conf
terraform plan -var-file=terraform.tfvars
terraform apply -var-file=terraform.tfvars
ssh -i ~/.ssh/oci ubuntu@public_ip
Name | Version |
---|---|
terraform | >= 1.10.4 |
oci | >= 6.21.0 |
tls | 4.0.6 |
Name | Version |
---|---|
oci | 6.21.0 |
tls | 4.0.6 |
No modules.
Name | Type |
---|---|
local_file.instance_ssh_private_key | resource |
local_file.instance_ssh_public_key | resource |
oci_core_instance.free_instance | resource |
oci_core_internet_gateway.free_internet_gateway | resource |
oci_core_route_table.free_route_table | resource |
oci_core_security_list.free_security_list | resource |
oci_core_subnet.free_subnet | resource |
oci_core_vcn.free_vcn | resource |
oci_identity_compartment.free_compartment | resource |
tls_private_key.instance_ssh_private_key | resource |
oci_core_images.instance_images | data source |
oci_identity_availability_domains.ads | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
fingerprint | The fingerprint for the user's RSA key. This can be found in user settings in the Oracle Cloud Infrastructure console. Required if auth is set to 'ApiKey', ignored otherwise. | string |
n/a | yes |
image_operating_system | The image's operating system. | string |
"Canonical Ubuntu" |
no |
image_operating_system_version | The image's operating system version. | string |
"24.04" |
no |
instance_boot_volume_size | The size of the boot volume in GBs. Minimum value is 50 GB and maximum value is 32,768 GB (32 TB). | number |
200 |
no |
instance_hostname | A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information. | string |
"free" |
no |
instance_memory | The total amount of memory available to the instance, in gigabytes. | number |
24 |
no |
instance_ocpus | The total number of OCPUs available to the instance. | number |
4 |
no |
instance_public_key_path | Public SSH key to be included in the ~/.ssh/authorized_keys file for the default user on the instance. | string |
"" |
no |
instance_shape | The shape of an instance. The shape determines the number of CPUs, amount of memory, and other resources allocated to the instance. | string |
"VM.Standard.A1.Flex" |
no |
private_key_path | The path to the user's PEM formatted private key. A private_key or a private_key_path must be provided if auth is set to 'ApiKey', ignored otherwise. | string |
n/a | yes |
region | The region for API connections (e.g. us-ashburn-1). | string |
n/a | yes |
tenancy_ocid | The tenancy OCID for a user. The tenancy OCID can be found at the bottom of user settings in the Oracle Cloud Infrastructure console. Required if auth is set to 'ApiKey', ignored otherwise. | string |
n/a | yes |
user_ocid | The user OCID. This can be found in user settings in the Oracle Cloud Infrastructure console. Required if auth is set to 'ApiKey', ignored otherwise. | string |
n/a | yes |
Name | Description |
---|---|
compartment-id | The OCID of the compartment. |
compartment-name | The name you assign to the compartment during creation. The name must be unique across all compartments in the parent. |
instance-name | A user-friendly name. Does not have to be unique, and it's changeable. |
instance-public-ip | The public IP address of instance VNIC (if enabled). |
instance-region | The region that contains the availability domain the instance is running in. |
instance-shape | The shape of the instance. The shape determines the number of CPUs and the amount of memory allocated to the instance. |
instance-state | The current state of the instance. |