title: Getting started with Oracle Cloud Infrastructure
description: Oracle Cloud Infrastructure's always free tier is very generous
date: 2021-09-05
tags:
- terraform
---
## Introduction
Oracle Cloud Infrastructure provides quite a generous always free tier for you to use and test their cloud... or host some light services. But getting started was a little difficult with many pieces missing or incomplete in the examples, especially how to configure ipv6 on your instances.
The documentation is very good and exhaustive but information was scattered : the following should help you get started right after you create your oracle cloud infrastructure's account.
## Create your API access
In order to terraform your infrastructure, you are going to need to generate an api access which is composed of a key and several other things :
- Open the web console, click the top left menu and select `Identity & Security` then `Users`.
- Click your account
- Scroll to bottom left and select `API Keys`
- click `Add an api key`
- Select `Generic API Key Pair`, download the private key file then click `Add`
- Copy the information displayed for the next phase
## Terraform
### Provider configuration
Here is the relevant snippet from my `providers.tf` file :
```hcl
variable "oracle_tenancy_ocid" {}
variable "oracle_user_ocid" {}
variable "oracle_fingerprint" {}
provider "oci" {
tenancy_ocid = var.oracle_tenancy_ocid
user_ocid = var.oracle_user_ocid
fingerprint = var.oracle_fingerprint
private_key_path = "../tf-common/oracle_key.pem"
region = "eu-amsterdam-1"
}
variable "oracle_amd64_instances_names" {}
```
This goes along with a `terraform.tfvars` file that you should fill with the api access information you saved up earlier :
The last bit is how I name the two free instances I want to create, pick anything you like.
### Networking
Here is how to bootstrap a vcn and the associated objects for direct internet access. For simplicity I will leave the access lists opened, firewall rules really are a pain to write with terraform... I plan to keep on using iptables or shorewall on the hosts for now.
Here is how to create the two always free tier instances, each in a different fault domain. The tricky part was to understand how ipv6 addresses are like second class citizens on oracle cloud :
name = var.oracle_amd64_instances_names[count.index]
value = oci_core_ipv6.amd64-vms-ipv6s[count.index].ip_address
type = "AAAA"
proxied = false
}
```
## Conclusion
Putting all of this together was an interesting experience, and I am satisfied that it works well. In the future I plan to add my own oci image based on alpine linux which is not available natively. I tried oracle linux and it is fine, but consumes way too much ram for my taste. For now I installed alpine linux using the instance's cloud console and [my procedure for that]({{< ref "docs/alpine/remote_install_iso" >}}).