What is Terraform?

The Lego analogy

What is Terraform?

Photo by Glen Carrie on Unsplash

What is it?

Terraform is a tool to build, change, and create infrastructure versions with security and efficiency through the code (https://developer.hashicorp.com/terraform).

In an analog way: Terraform is like a magical tool that lets you create an entire Lego city all at once, without having to build each piece separately. You can tell Terraform what you want your city to look like, and it will shape the land, put buildings in place, and create roads according to your instructions. It's like having a superpower to make your dream Lego city come to life in an easy and fast way.

Main features

  • Infrastructure as Code (IaC)

  • Declarative language

  • It allows versioning (infra evolution and automation)

  • Idempotent (means doing something many times won't change it more)

  • High-level syntax and reusable

  • Environment parity

  • Execution plans

  • Security and predictability

  • Separation from the plan and apply

  • Hybrid

  • Agnostic

  • It can deploy to multiple providers at the same time

Use cases

  • It can create or provision a new infrastructure;

  • It can manage the existing infra;

  • It can replicate the infra.

How does Terraform work?

Terraform is like a magical building blocks for the computer world. You use it to create and manage things in the digital realm, just like you'd use LEGO to build in the real world. You tell Terraform what you want, like a virtual house, roads, or trees, and it follows your instructions written in a special file. Then, Terraform acts like a super-fast and super-smart builder, constructing your digital creations exactly as you described them. If you change your mind, you can tell Terraform to make adjustments.

And how does Terraform do that?

Through the providers:
A Terraform provider is like a special toolbox that helps you build different things in different places in the computer world. Just as you use different tools for making LEGO creations, like a treehouse in a magical forest or a spaceship in outer space, you choose the right provider for your digital project. Each provider kit has tools and instructions specific to the place you want to build in, ensuring you can create all sorts of digital stuff in the right way, whether it's in a forest, a city, or any digital location you want to build in. Providers are like your digital toolsets for different building adventures!

Providers expose resources, giving the possibility to create infrastructure in all these platforms below:

  • IaaS: AWS, GCP, Azure

  • PaaS: Kubernetes, Heroku, Digital Ocean

  • SaaS: New Relic, Datadog

List of Terraform providers: https://registry.terraform.io/browse/providers

Terraform vs. Other Softwares

  • Terraform is a high-level orchestration tool.

  • Ansible, Puppet, Chef, and other tools manage the configuration;

  • It is not Terraform's purpose to manage the config;

  • Providers can use those tools;

  • CloudFormation and other IaC tools: they only support one specific vendor.