Install Terraform inside the Linux Machine - Terraform in GCP Compute Engine.

Terraform Tutorials: Learn Step by Step with images How to install Terraform inside Linux based Google Compute Engine.
Written by Paayi Tech |17-Oct-2020 | 0 Comments | 174 Views

Now we know What is Terraform?. The Next Step is to download and install the terraform inside the Linux server. If you are following me, then you know I create a brand-new Linux based machine inside GCP Compute Engine. I installed Nginx also in it for the demo perspective. 

If you haven’t checked that article, then please take a look into it: Create a Linux based GCP compute inside the GCP console

 In this topic, I will install a terraform inside a Linux machine using the GCP compute engine.  As you already knew that we created a Linux machine named terraform.  

Please follow the following steps to install the terraform in this Linux machine. 

The first step is to SSH into that terraform machine. Please check the image below and do the same. 

ssh-into-the-new-machine---paayi-terraform-tutorials

 

When you SSH into the Linux machine, this is the fresh look of the new device.

after-successful-login-into-ssh-this-screen-will-come---paayi-terraform-tutorials

 

The second step is to update all the packages in the Linux machine using this command.

:sudo apt-get update 

 You can also use this command if you have centos. 

:sudo yum update 

 

 The above commands in action, will look as shown in the image below.

update-all-packages---paayi-terraform-tutorials.png

 

We need Wget to command to download the terraform from the link, and we copy in some time and Unzip command to unzip the downloaded terraform zipped file. For that, we need to check if those commands are available or not. If not, then we will install those commands first. 

As you see in the image below, we don’t have these commands available. 

we-need-wget-and-unzip-and-its-not-there-paayi-terraform-tutorials.png

 

The third step is to install wget and unzip using these commands. I wrote the command in which you can download both wget and unzip.  

:sudo apt-get install wget unzip 

 But you can write both commands separately, also as shown below. 

:sudo apt-get update wget 

:sudo apt-get install unzip 

 

install-unzip-and-wget-in-linux-machine---paayi-terraform-tutorials

 

The fourth step is to find the link of terraform which you need to download inside your Linux machine. Open google and write download terraform, as shown in the image below. 

now-search-download-terraform-in-google---paayi-terraform-tutorials

 

 

Click on the first link, and it will take you directly to the terraform download page.  

Download-terraform-page---go-down-and-search-linux-software---paayi-terraform-tutorials`

 

 

 

Find the Linux exe and right-click on the 64bit and click the copy link, as shown in the image below. 

right-click-on-64-bit-and-copy-the-link---paayi-terraform-tutorials

 

The fifth step is to download the terraform using the wget command as shown below 

: wget https://releases.hashicorp.com/terraform/0.13.2/terraform_0.13.2_linux_amd64.zip 

 

As I am writing this article, Terraforms 0.13.2 version is the latest version available on the terraform website.  

wget and paste the link to download terraform--paayi-terraform-tutorials

 

Check if it’s adequately downloaded or not using the command as shown below 

: ls –la 

 

terraform-downloaded---paayi-terraform-tutorials.png

 

Now unzip the zipped terraform using the unzip command as shown below 

: unzip terraform_0.13.2_linux_amd64.zip 

 

unzip-downloaded-terraform---paayi-terraform-tutorials.png

 

The sixth step is to make a new downloads directory and move the unzipped terraform version in it as shown below 

: mkdir downloads 

: mv terraform downloads 

 

mkdir-downloads-and-move-downloaded-terraform-in-it---paayi-terraform-tutorials.png

 

The seventh step is to set the path of the terraform in our bash profile.  

Find out the profile using ls –la. 

Then open the .profile using Vim as shown below 

: vim ~/.profile 

 

need-to-declare-the-downloads-path-for-terraform-inside-your-machine-profile---paayi-terraform-tutorials.png

 

In the Vim, add this value 

: export PATH = ‘$Path:~/downloads’ 

To exit from Vim, press ESC first, then :wq and press enter it will save everything and let you escape from the Vim.

 

 

add-this-line-inside-your-dot-profile---paayi-terraform-tutorials.png

 

It will not automatically update the path for your current session, and for that, you need to do this final step that is to update your path using the source command. 

: source ~/ .profile 

 

declare-source-for-terraform---paayi-terraform-tutorials.png

 

Now check if terraform is installed or not using this terraform command 

: terraform 

 

terraform-installed---paayi-terraform-tutorials.png

 

So you saw step by step how we installed inside Linux based machine. Now in the next few articles, I will show you how to create a Terraform project, setup service accounts inside GCP. Enable APIs inside GCP to work seamlessly with Terraform. Setting up a remote state in Google cloud storage, and we will use Google Cloud Storage instead of our local machine storage.

 

 





Login/Sign Up

Comments




Related Posts



© Copyright 2020, All Rights Reserved. paayi.com

This site uses cookies. By continuing to use this site or clicking "I Agree", you agree to the use of cookies. Read our cookies policy and privacy statement for more information.