Terraform IAC: Tips & Tricks

varunkumar inbaraj
2 min readJun 11, 2022

GCP Terraform Series 1

Terraform is one of the most popular IAC(infrastructure as code) tools used by every cloud engineer. You can define both cloud and on-premise resources in human-readable configuration files and thereby provision these resources programmatically. It is not limited to a single cloud provider. You can use Terraform to run your applications on multiple cloud platforms simultaneously.

Terraform is an open-source IAC tool created by HashiCorp.

Google Cloud Managing IAC

Benefits:

  1. No room for human errors.
  2. Quality, consistency, and efficiency of Cloud and on-prem infrastructure.
  3. It uses the HCL language, which is fairly similar to JSON and easy to learn and use.
  4. This avoids the need to learn multiple IAC tools(AWS-IACs, GCP-IACs, Azure-IACs) and improves the scope of collaboration.

Terraform providers to interact with APIs

Write: Author the infrastructure as code.

Plan: Preview changes Terraform will make before applying.

Apply: Provision the infrastructure and apply the changes.

The benefit of Terraform State

To know the current state of configurations and infrastructure under its management, Terraform stores this information in a file called the state file. It is a critical component of Terraform.

Terraform Backend

Terraform backend is the platform where the Terraform State Snapshots are stored. By default, Terraform uses a backend called local to store state as a local file on your disk. All other supported backends are some kind of remote storage service.

The provider in Terraform

Providers in Terraform are plugins that allow Terraform to interact with cloud providers, SaaS providers, and other APIs. For example, if we plan on using Terraform to provision infrastructure on GCP, we will need to declare a GCP provider in our configuration files.

You will see a lot of tips in the series.

--

--