Introduction To Terraform

By — SANDEEP KUMAR PATEL

What is Terraform?

Terraform is an open source “Infrastructure as Code” tool, created by HashiCorp.

A declarative coding tool, Terraform enables developers to use a high-level configuration language called HCL (HashiCorp Configuration Language) to describe the desired “end-state” cloud or on-premises infrastructure for running an application. It then generates a plan for reaching that end-state and executes the plan to provision the infrastructure.

Because Terraform uses a simple syntax, can provision infrastructure across multiple cloud and on-premises data centers, and can safely and efficiently re-provision infrastructure in response to configuration changes, it is currently one of the most popular infrastructure automation tools available. If your organization plans to deploy a hybrid cloud or Multicloud environment, you’ll likely want or need to get to know Terraform.

Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.

The key features of Terraform are:

  • Infrastructure as Code:- Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your datacenter to be versioned and treated as you would any other code. Additionally, infrastructure can be shared and re-used.
  • Execution Plans:- Terraform has a “planning” step where it generates an execution plan. The execution plan shows what Terraform will do when you call apply. This lets you avoid any surprises when Terraform manipulates infrastructure.
  • Resource Graph:- Terraform builds a graph of all your resources, and parallelizes the creation and modification of any non-dependent resources. Because of this, Terraform builds infrastructure as efficiently as possible, and operators get insight into dependencies in their infrastructure.
  • Change Automation:- Complex changesets can be applied to your infrastructure with minimal human interaction. With the previously mentioned execution plan and resource graph, you know exactly what Terraform will change and in what order, avoiding many possible human errors

Terraform Core concepts

Below are the core concepts/terminologies used in Terraform:

  • Variables:- Also used as input-variables, it is key-value pair used by Terraform modules to allow customization.
  • Provider:- It is a plugin to interact with APIs of service and access its related resources.
  • Module:- It is a folder with Terraform templates where all the configurations are defined
  • State:- It consists of cached information about the infrastructure managed by Terraform and the related configurations.
  • Resources:- It refers to a block of one or more infrastructure objects (compute instances, virtual networks, etc.), which are used in configuring and managing the infrastructure.
  • Data Source:- It is implemented by providers to return information on external objects to terraform.
  • Output Values:- These are return values of a terraform module that can be used by other configurations.
  • Plan:- It is one of the stages where it determines what needs to be created, updated, or destroyed to move from real/current state of the infrastructure to the desired state.
  • Apply:- It is one of the stages where it applies the changes real/current state of the infrastructure in order to move to the desired state.

Terraform File Extensions-

  1. Sandeep.tf
  2. Sandeep.tfvars
  3. Sandeep.tf.json
  4. Sandeep.tpl

Terraform Lifecycle-

Terraform lifecycle consists of — init, plan, apply, destroy.

  1. Code development
  2. Code formatting with terraform fmt
  3. Initialization with terraform init
  4. Code validation with terraform validate
  5. Planning with terraform plan
  6. Manual verification of Terraform changes on infrastructur

More Information-

Thank for your Time………..!!!!!!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sandeep Kumar Patel

Sandeep Kumar Patel

58 Followers

Enthusiastic, aspirant in artificial intelligence, machine learning Research is formalized curiosity. It is poking and prying with a purpose.