Various Tutorials
  • About
  • Tutorials
    • 1. Instance for deployment
      • Create instance
      • Install and configure OCI CLI
      • OCI CLI small test
      • Install and configure Terraform
      • Terraform - small test
    • 2. OCI Networking &Terraform
      • 2.1 VCN (basics)
        • 2.1.1 Create a virtual network using Start VCN Wizard
        • 2.1.2 VCN & public subnet (step-by-step in Terraform)
        • 2.1.3 VCN & public subnet (new compartment)
        • 2.1.4 VCN, Terraform and Ansible (Nginx example)
        • 2.1.5 VCN & private subnet (step-by-step in Terraform)
      • 2.2
      • 2.3
    • 3. Untitled
    • 4. Untitled
    • 5. ATP and APEX
      • Setup Autonomous Database
        • Deploying ATP using OCI Interface
        • Deploy with OCI CLI
      • Setup APEX on ATP
      • Connect remotely to ATP
      • ATP, APEX and Jupyter
      • Demo
    • 6. MySQL
      • 6.1. The basics - OCI UI (MySQL DB System)
      • 6.2 The basics - OCI CLI (MySQL DB System)
      • 6.3 Access MySQL DB System
      • 6.4 HeatWave and MySQL DB Service
      • 6.5 Python SDK
      • 6.6 MySQL Replication (Compute Instances)
      • 6.7 Monitoring MySQL instances
        • Deploy MySQL instances
        • Monitoring tools
          • 1. Networking setup
          • 2. Prometheus setup
          • 3. MySQL Prometheus Exporter Setup
          • 4. Grafana setup
          • 5. Grafana metric graphs
    • 7. MySQL OCI &Terraform
      • 7.1 Deploy MySQL DB System with Terraform (basic tutorial)
      • 7.2 Deploy MySQL DB System with Terraform and access the system
      • 7.3 Endpoints
      • 7.4 Channels (troubleshooting)
        • Fixed MySQL source - MDS replication
      • 7.5 Channels (code)
Powered by GitBook
On this page
  • Install Terraform
  • Setup Terraform for OCI Cloud
  1. Tutorials
  2. 1. Instance for deployment

Install and configure Terraform

PreviousOCI CLI small testNextTerraform - small test

Last updated 4 years ago

Install Terraform

Become root user, and let's perform a few updates

ubuntu@deploymentmachine:~$ sudo -i
root@deploymentmachine:~#
root@deploymentmachine:~#
root@deploymentmachine:~# apt-get update
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]
Hit:2 http://eu-frankfurt-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal InRelease
[...]

from link: https://learn.hashicorp.com/tutorials/terraform/install-cli

Hashicorp provides a very useful tuturial on how to install Terraform, depending on your OS:

Since my machine is on Ubuntu, I will perform the Linux steps:

  • Add key and official repository


root@deploymentmachine:~# curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
OK
root@deploymentmachine:~# apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
Get:1 https://apt.releases.hashicorp.com focal InRelease [4419 B]
Hit:2 http://eu-frankfurt-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://eu-frankfurt-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://eu-frankfurt-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:5 http://security.ubuntu.com/ubuntu focal-security InRelease
Get:6 https://apt.releases.hashicorp.com focal/main amd64 Packages [17.9 kB]
Fetched 22.3 kB in 1s (40.6 kB/s)
Reading package lists... Done
  • Perform updates so changes can take place:

root@deploymentmachine:~# apt-get update
Hit:1 https://apt.releases.hashicorp.com focal InRelease
Hit:2 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:3 http://eu-frankfurt-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal InRelease
Hit:4 http://eu-frankfurt-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:5 http://eu-frankfurt-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-backports InRelease
Reading package lists... Done
  • Intall Terraform

root@deploymentmachine:~#
root@deploymentmachine:~# apt-get install terraform
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  terraform
0 upgraded, 1 newly installed, 0 to remove and 38 not upgraded.
Need to get 33.5 MB of archives.
After this operation, 81.8 MB of additional disk space will be used.
Get:1 https://apt.releases.hashicorp.com focal/main amd64 terraform amd64 0.14.5 [33.5 MB]
Fetched 33.5 MB in 6s (6042 kB/s)
Selecting previously unselected package terraform.
(Reading database ... 68575 files and directories currently installed.)
Preparing to unpack .../terraform_0.14.5_amd64.deb ...
Unpacking terraform (0.14.5) ...
Setting up terraform (0.14.5) ...
  • Check if installation has been a success by running a simple command:

root@deploymentmachine:~# terraform -version
Terraform v0.14.5
root@deploymentmachine:~#
root@deploymentmachine:~#

Setup Terraform for OCI Cloud

You will need to provide the following environment variables:

export TF_VAR_tenancy_ocid="ocid1.tenancy.oc1..aaaaaasomefaketenancyidinhereaaaaa323423421"
export TF_VAR_compartment_ocid="ocid1.tenancy.oc1..aaaaaasomefakecompartmentidinhereaaaaa323423422"
export TF_VAR_user_ocid="ocid1.user.oc1..aaaaaasomefakeuseridinhereaaaaa323423423"
export TF_VAR_fingerprint="2x:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
export TF_VAR_private_key_path="/root/.oci/oci_api_private_key.pem"

In case you have not setup your .oci folder or you are not aware how to find these details, check my tutorial on - it explains step by step how to setup a fingerprint, a private key and how to find the rest of required information.

Once you have completed all these steps, go to next tutorial, to make sure your configuration is setup correctly.

Install and configure OCI CLI
Terraform - small test,
Install Terraform | Terraform - HashiCorp LearnHashiCorp Learn
Logo