One of my old colleague whom I had pleasure to work with many years ago asked recently if there would be guide on getting a database running on Oracle Cloud Infrastructure with Terraform using Infrastructure as Code.
That led me to an idea that I could write such guide and describe each step why it’s required and what are the key details on that service.
Different areas on this 10-part series will be:
Each post will have the required Terraform code and finally in the last post I will combine everything together so you can use it as a baseline. I’ll post the source code as well in the wrap-up.
Contrary to normal where I use Terraform modules this setup will not use modules but just a single folder having all necessary files in place to make the overall setup easier to understand.
After this series you will have a basic network with database running on private network and a compute instance to be used as a jump server in the public network which has access to the private network as well.
This one is the easy part! Unless you are using Oracle Linux which automatically includes Terraform in the repository you will need to download Terraform from https://www.terraform.io/downloads.html .
Earlier you also had to download the OCI provider but now since OCI is an official provider it is included without further steps. Documentation and setup steps are described in the Terraform OCI provider page https://www.terraform.io/docs/providers/oci/index.html.
Creation of API key is described in detail here. On the same link you can see how to assign it for your user.
In short (and copied from above documentation) the values you need to setup as environment variables are:
On windows you can set these using setx command or by opening Environment variables under control panel and setting them.
Once these are set we can set the variables to be used in our Terraform file. I will have three files in this project – main.tf, variables.tf and outputs.tf.
In the main.tf I define environment variables in the provider section:
provider "oci" {
tenancy_ocid = "${var.tenancy_ocid}"
user_ocid = "${var.user_ocid}"
fingerprint = "${var.fingerprint}"
private_key_path = "${var.private_key_path}"
region = "${var.region}"}
These variables come from variables.tf where they are referenced to come from the environment variables we have set.
variable "tenancy_ocid" {} // Your tenancys OCID
variable "user_ocid" {} // Your user's OCID
variable "fingerprint" {} // Fingerprint for the user key, can be found under user in console
variable "private_key_path" {} // Where your private key is located on the server you are running these scripts
variable "region" {} // Which region is used in OCI eg. eu-frankfurt-1
Now all the necessary pre-requisistes have been done and we can start creating the resources in the next parts. Part 2 will discuss creation of compartments.
Last time I showed how to provision Autonomous Database Serverless (ADB-S) on Google Cloud. This…
I bet few years back folks didn't expect that by 2024 we would be able…
This will NOT be a technical walkthrough on Oracle Database@Azure but rather my opinions and…
Recently OCI announced small but VERY useful service, IP Address Insights. Why this matters? I've…
View Comments