Before you begin working with Terraform, you will need to understand how to install it on your current system. This is the foundational step to make sure you are able to use this cutting-edge tool in DevOps. In this hands-on lab, we will learn how to install terraform on a CentOS 7 instance.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Create an Instance
- From Google Cloud console’s main navigation, choose Compute Engine.
- Click Create.
- Give your instance a name.
- Change the boot disk to CentOS 7.
- Click Create.
- Log in to the Instance via SSH and Download Terraform
From Google Cloud navigation, choose Compute Engine.
In the main window pane, click Create.
Name your instance
terraform-instance
.In the Boot disk section, click Change.
Set Operating system to CentOS.
Set Version to CentOS 7.
Click Select.
Click Create.
Click SSH next to
terraform-instance
.Install necessary updates:
sudo yum update -y
sudo yum install wget unzip -y
Download Terraform:
wget https://releases.hashicorp.com/terraform/0.12.23/terraform_0.12.23_linux_amd64.zip
Unzip the file:
unzip terraform_0.12.23_linux_amd64.zip
Move Terraform to a directory called
temp
:mkdir temp/
mv terraform temp/
Input the path to communicate with Terraform into the
/etc
profile file:echo "PATH='$PATH:~/temp/'" >> .bash_profile
Use the following in order to be able to call Terraform:
source .bash_profile
Call Terraform:
terraform