Skip to content
Creates demo stack in Oracle Cloud Infrastructure (OCI) with a database and necessary networking components using OCI Resource Manager
HCL
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Mar 7, 2019
README.md Update README.md Mar 7, 2019
main.tf Initial files Mar 7, 2019
outputs.tf Initial files Mar 7, 2019
variables.tf Added missing variables Mar 7, 2019

README.md

tf-database-demo-resource-mgr

Creates demo stack with Oracle Cloud Infrastructure (OCI) Resource Manager using Terraform which creates an Oracle database and necessary networking resources.

Running this in OCI Resource Manager creates following resources:

  • Compartment
  • Virtual Cloud Network (VCN)
  • Nat Gateway
  • Internet Gateway
  • Public & Private subnets in the VCN
  • Public & Private routetables - Public RT will have a route to Internet Gateway and Private RT route to NAT Gateway
  • Public & Private securitylists - Public SL allows traffic to ports 22 and 3389 only. By default it allows traffic from any source but this can be modified to allow only traffic from CIDR block deemed necessary
  • One compute instance with the smallest shape to act as a jump server and a 7.6 linux image - the instance public IP will be displayed in the end.
  • One Standard Edition database with the option LICENSE_INCLUDED

Requirements and install instructions

  1. Valid OCI account to install these components
  2. Download these .tf files as a zip and navigate in OCI under Resource Manager
  3. Press "Create Stack" and upload created zip file as your new stack
  4. Navigate inside the stack and from the left side menu "Resources" click Variables and Edit Variables
  5. Add following variables:
  • region (the name of region you are operating for example eu-frankfurt-1)
  • tenancy_ocid (your tenancy's OCID - from left side menu Administration -> Tenancy Details)
  • ssh_public_key (ssh key to be used - you can find create instructions from here) Note that you should not paste keys here if you would use this in any other than demo purposes
  1. Navigate inside stack and press Terraform Actions -> Plan, this usually runs 2-3 minutes
  2. If Plan succeeded without issues run Terraform Actions -> Apply, this creates resources and will run around 60-90 minutes
  3. Review the public IP of compute instance and the private IP's for compute and database instance. You can use the private ssh key and opc user to login to these instances

Removal of stack

In case you want to remove created stack:

  • Navigate inside stack and press Terraform Actions -> Destroy, this will remove all the created resources

Additional notes

You can freely change the variables in the variables.tf depending what you need. One could potentially scale down the database shape, open different ports in security list or change database version. Try and test!

Thanks for Stephen Cross for the filtering of OCI images using specific OS version.

Using without resource manager

Incase you don't want to use this with Resource Manager there are slight edits you will need in variables.tf and main.tf. Also you should have following environment variables set in your machine where you are running Terraform and set up your keys in OCI for the user.

Set following environment variables:

  • TF_VAR_tenancy_ocid - Your tenancy OCID
  • TF_VAR_user_ocid - Your user OCID which you are connecting to OCI
  • TF_VAR_fingerprint - Fingerprint for your key found from user details
  • TF_VAR_private_key_path - Path to your private key on your machine
  • TF_VAR_region - region which you are using

Running Terraform:

  • terraform init
  • terraform plan !! Remember to review the plan !!
  • terraform apply

To remove resources:

  • terraform destroy

Edit main.tf provider:

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}"
}

Edit variables.tf and add:

variable "tenancy_ocid" {} // Your tenancy's 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 
You can’t perform that action at this time.