Skip to main content

Command Palette

Search for a command to run...

Terraform Basics

Published
4 min read
Terraform Basics

Let us discuss the concept of IAC before we discuss about Terraform Lets look at the traditional way of IT delivery to appreciate the utility of IAC tools.

The Traditional Way of managing Infrastructure.

App delivery in a traditional IT environment

The management of the business organization wants to roll out an application

They give the requirements for the application

The business analyst gathers needs and comes out with a set of high-level technical requirements.

These are passed to the Solution Architect who comes up with the architecture for the deployment of the application like the type, specs and count of servers needed for front end web serves, backend web servers, databases, loadbalancers

Traditionally this would be deployed in the on-prem environment (using resources in the datacenter)

For any additional hardware, the procurement team places an order with the vendor who’d purchase and deliver to the datacenter from anywhere between a few days, weeks or months.

Once the hardware is received, the field engineers from the client are responsible for the setting up the hardware on a rack. ( rack and stack)

The sys admins do the initial configs on the systems and network engineers make them available on the network.

Storage admins assign storage to the servers

The backup admins configure backups.

Once the systems are setup as per the standards, they are then handed over to the app teams for deploying the apps.

This deployment models has quite a few disadvantages.

1. High turn around time. (From weeks to months)
2. Slower scaling time (Both scale up and scale down)
3. Overall cost to maintain this model quite high
4. Limited automation - Some aspects can be automated while others like rack and stack, cabling and deployment are manual and slow
5. Chances of human error high as many teams are engaged in many tasks which result in inconsistent environment.
6. Another major disadvantage – under-utilization of compute resources.

So organizations have been moving to virtualization and cloud computing to take advantage of cloud services

Overall time to setup infrastructure and Time to Market of Apps are significantly reduced

As datacenter and h/w are managed by the cloud service providers Infrastructure costs to manage h/w resources are reduced.

Cloud platforms support APIs, thus opening a huge opportunity for automation.

Built-in scaling capabilities helps to reduce resource wastage.

Cons of Web based Cloud platforms

We could provision infrastructure using the web interface provided by the platform however, it is not efficient in case of larger number of resources

Still the infrastructure needed to be handed over to various teams for application setup giving way for human errors.

Companies started to solve this using scripts and other tools for infrastructure provisioning and managing resources and environments. These became the IAC

Types of IAC Tools

One way of infrastructure provision is using the web console of cloud platforms or the provisioning process can be codified using scripts and programming languages

Thus we can write and execute code to define, provision, configure, update and eventually destroy infrastructure resources. This process or concept is known as Infrastructure as Code (IaC)

Using this concept almost any infrastructure component can be managed as code.

IAC has evolved to defining infrastructure using simple, human readable and high level language

IAC tools are designed with a specific goal in mind. Based on these, there are three types of IAC tools

  • Configuration management
  • Server templating
  • Provisioning tools

Features of Configuration management tools are:

They are designed to install and manage software into existing infrastructure resources viz. Servers, db, networking devices etc.

Unlike shell scripts, these tools maintain a consistent and std structure of code making it easier to manage and update them as needed.

Can run or execute on multiple remote resources at once.

Can be checked or saved into a VCS allowing to distribute and reuse

Most important feature - They are idempotent ie they can run multiple times and each time it will only make changes necessary to bring the environment to a desired state. - meaning it’ll leave anything already in place as it is.

Features of Server templating tools

Examples are docker, packer and hashicorp vagrant

What do they do – create custom images of a virtual machine or container containing all necessary software and dependencies installed on them

Eliminates the need for installing software on the deployed virtual machine or container. Examples images on docker hub, custom images in AWS ECR etc.

They promote immutable infrastructure – means once a vm or container is deployed, it usually remains unchanged.

If changes are to be made to images then changes are made to the images and a new instance is deployed using the updated image. rather making changes to running instances as in the case of config. mgmt tools.

Features of Provisioning tools

They are used to provision infrastructure components like servers, db, subnets etc using simple declarative code.Examples are Terraform, AWS CloudFormation etc.

Terraform is vendor or platform agnostic and support provider plugins for all major cloud computing providers.

More from this blog

The Continuous Journey

24 posts