Saturday, August 8, 2020

Terraform

Next.

 In this series of blogs, we are going to discuss, how we can use terraform to manage the Infrastructure (provisioning, update and destroy).  

This is first the blog of terraform series, In this blog we are going to cover below topics.

What is IaC (Infrastructure as Code)?
What is Configuration management tools?
What is Infrastructure Orchestration tools?
What is terraform?
Terraform Installation


What is IaC (Infrastructure as Code)?

In simple terms, IaC is the way to manage the Infrastructure (provisioning, update and destroy) using code. This code should be written in simple human readable configuration file. Like YAML, JSON etc.

IaC tools is classified in two major types according their primary uses.

1)Configuration Management Tools:

These tools are primarily designed for Installation/Un-installation/ updation of the software and patches on existing servers.

e.g.  Ansible, Puppet, Chef, saltstack etc.

2)Infrastructure Orchestration Tools:

These tools are primarily designed for creation/updation/deletion of the virtual servers and other Infrastructure resources.

e.g. AWS CloudFormation, Azure ARM templates, Terraform etc.

You can do the Infrastructure Orchestration tasks with help of Configuration Management Tools as well, but they are not primarily designed for that.

e.g. Ansible has many modules for provisioning and de-provisioning of the virtual server in different cloud environment, but the primary focus of Ansible is Installation /Uninstallation /updation of the software and patches on existing servers.

Sometime we use the Cloud Infrastructure API’s to manage the resources in our favorite programming language like C#, python, java etc but remember this is not coming under IaC, As I wrote in earlier section of the blog, that the language should be in human readable configuration language. like HCL (Hashicop configuration language), JSON (Java script object notation), YAML (yet another markup language) etc.

We can use “Infrastructure Orchestration tool” and Configuration Management tools” in our environment to better manage the infrastructure . As per the best practice , always try to assign such job to tools , for which it is primarily built.

Below Diagram ,How to use  "Infrastructure Orchestration tool” and Configuration Management tools” to manage infrastructure efficiently. 

Infrastructure Tool and Configuration Tool Integration
What is Terraform?

Terraform is IaC tool, and that comes under Infrastructure Orchestration category. With help of Terraform you can manage your infrastcrure using human readable configuration files. Terraform is opensource IaC Tool created by HashiCorp and written in the Go programming language. In Terraform Configuration file are written in HCL (Hashicop configuration language) language.

Terraform Installation

Hashicop provide two type of terraform offering.

Community Edition (Open Source)

Enterprise Edition

We will discuss and take examples using community Edition of terraform in entire blog. For learning point of view, Community Edition is sufficient.

You can install terraform on major OS like Linux, Window, Mac OS and Solaris. Installation process is very simple and straight forward.

You need to download the terraform file from Hashicop site and copy it to the suggested location as per Hashicop documentation. 

1)Linux:

Here I am taking example of Linux 64-bit OS, you can download file as per your machine architecture.

Step :1 Download the Zip package from terraform site in any directory.

   $ sudo wget https://releases.hashicorp.com/terraform/0.12.29/terraform_0.12.29_linux_amd64.zip

Step :2 Unzip downloaded file using unzip command. You will get a file named as terraform.

   $ sudo unzip terraform_0.12.29_linux_amd64.zip

Step :3 move terraform file which you got from unzip command to “/usr/local/bin/” location.

  $ sudo mv terraform   /usr/local/bin/

Step :4 verify the version.

 $ sudo  terraform - -version

 Output: Terraform v0.12.29 

2)Windows:

Step :1 Download terraform file Zip file as per your machine architecture from terraform site.

Step :2 Unzip the downloaded file, you will find terraform.exe file.

Step :3 Copy this terraform.exe file in any folder on system and add this path in environment variable under path key.

Step :4 verify the version.

Open PowerShell and type below command.

  $ sudo  terraform - -version

 Output: Terraform v0.12.29

Next.


Cheers!
Sandeep 
https://www.linkedin.com/in/sandeep-sharma-40a40b22/



3 comments:

Terraform State file

Previous This is the third blog post of terraform series. In this blog post, we are going to discuss terraform state file. We are going to...