angacom expo

17-19 June

Bella Center, Copenhagen, Denmark

DTW Ignite 2025

Let's meet!
CEO Volodymyr Shynkar
HomeBlogTerraform for Beginners How and Why?
TechnologiesTerraformTools

Terraform for Beginners How and Why?

2 mins
20.10.2022
Volodymyr Shynkar CEO and Co-Founder of AppRecode

Volodymyr Shynkar

CEO/CTO

Introduction

Since DevOps practice is designed to improve the quality and speed of the entire SDLC process, there are many tools to work with each stage of it (or if not, we always have bash:)

In this article, we will talk about one of the most popular tools in the direction of Infrastructure as Code (IaC), namely – Terraform.

Why? IaC Basics

Infrastructure as code (IaC) is an approach to automating infrastructure deployment and changes by defining the desired state of resources and their relationships in code.

In other words, suppose we need to prepare a simple (or not) infrastructure for deploying a web application with a network, a database, the appropriate instance type, and other configurations of all the listed elements. Of course, all this can be done through the web console of the cloud provider you decide to work with (by the way, the list of such providers is described here, or you can even write your own provider), but during development, such an environment often needs to be changed, reproduced and duplicated for different environments. Therefore, it is not suitable to do it manually, as it is long, tedious, expensive, and also carries with it a high level of errors.

So, IaC avoids manual configuration and enforces consistency by well-documented code representing the desired environment state. Terraform uses its own “hcl” syntax for this.

Installation

You could use the needed flow depending on your system from the HashiCorp docs
(https://learn.hashicorp.com/tutorials/terraform/install-cli).

The Basic File Structure of Terraform Project

  • *.tf – files of your terraform config
  • .terraform – folder with downloaded modules and provider files (is created after init)
  • terraform.tfstate – local state if you don`t use remote state (is created after init)
  • .terraform.lock.hcl – file with provider versions and their hashes (is created after init)

How to use it?

After writing the configuration you want to deploy, use the basic commands below.

Main commands:

  • init – to initialize working directory
  • validate – validate configuration on syntax error
  • plan – show changes required by the current configuration
  • apply – create or update infrastructure
  • destroy – destroy previously-created infrastructure

Alternative Tools

  1. AWS CloudFormation
  2. Ansible
  3. Chef
  4. Puppet

Did you like the article?

0 ratings, average 0 out of 5

Comments

Loading...

Blog

OUR SERVICES

REQUEST A SERVICE

651 N Broad St, STE 205, Middletown, Delaware, 19709
Ukraine, Lviv, Studynskoho 14

Get in touch

Contact us today to find out how DevOps consulting and development services can improve your business tomorrow.