Terraform Introduction

Shivangi Sharma
3 min readJun 12, 2020

--

With the increasing demand of multi-hybrid cloud , the demand for IAS tools is also increasing rapidly. One of the most common IAC tool is terraform.

Terraform is an open-source infrastructure as code (IAC) software tool created by HashiCorp. It enables users to define and provision a data center infrastructure using a high-level configuration language known as Hashicorp Configuration Language or HCL

Basically, Terraform is a tool to manage multi-clouds.

The main advantage of using terraform is:

  • It is a standard tool for all cloud services (public + private ) like AWS, Azure, GCP, Openstack, etc. , thus it provides standardization
  • Has started extending support for other tools such as Kubernetes, Github, etc.
  • Provides infrastructure as a code, which is extremely beneficial for large-scale companies

Lets start by creating an AWS ec2 instance by using terraform-

firstly, we need to set up terraform:

  • download terraform
  • add terraform to the path variable

Making variables in terraform:

first method
second method
both methods show same output

Creating an AWS instance:

1. We can create a new profile for the user so that we don't have to enter ACCESS KEY and SECRET KEY by using simple AWS commands in CLI

aws configure — profile user1

then create an ec2.tf file

notepad ec2.tf

In ec2.tf:

launched an instance “

2. use command terraform init

this command might take some time as its installing the necessary plugins in the workspace

3. use command terraform apply

Instance launched on AWS

Congratulations!! your ec2 instance has been created

Now we will create-

  1. two ec2 instances
  2. create an EBS volume
  3. attaching the EBS volume

--

--