One Stop Cloud
Published in

One Stop Cloud

Terraform Best Practices

Terraform Backend for storing Tfstate file

Terraform stores the infrastructure information in the tfstate file. By default, Terraform stores the tfstate files in the locally. Because tfstate file has all infra details, it’s better to store it remotely. To remotely store the tfstate file Terraform provides a feature called Terraform backend. Terraform backend allows you to store the tfstate files in S3, blob storage, cloud storage, etcd, jfrog, etc. Most of the Terraform backend also allows state locking. State locking means updating of terraform infrastructure can only be done sequentially. Updating parallelly of the same infrastructure is not allowed.

Terraform Workspaces for managing various environments

Terraform allows you to configure multiple environments using workspaces. Create the workspaces to isolate dev, stage and prod environments. Use terraform backend and Workspaces to isolate different environments.

Tag resources

Tag all the resources which you can. Tagging help search the resources easily. Also, mainly tagging can be used to identifying resources during billing.

Use TFVARS file

Store all the variable values in the Tfvars file. Hence you can use the same code with multiple Tfvars files to build different environments. Using default values in variables.tf is not a sustainable practice.

Use Modules

The open-source community provides predefined modules for creating the infrastructure. Understand and use them

If modules are not readily available, then create the custom modules. This helps with the reusability of the code.

Blog will show showcase different solutions for Cloud

Recommended from Medium

Day 59: Windows API for Pentesting (Part 1)

CS371p Spring 2022: David Klingler

10 TIPS TO IMPROVE YOUR WEBSITE LOADING SPEED

Setup Hygieia dashboard on Azure Kubernetes (AKS)

Digital Twin as Code (DTaC)

Algorithm Visualizer

Is Learning a Programming Language like Learning a Foreign Language?

Groovy scripts in SAP Commerce(Hybris)

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
Sushma & Dixon

Sushma & Dixon

....

More from Medium

Terraform CLI Cheat Sheet

VPC👉 IG👉ELB👉RDS using Terraform IAC

IaC using Terraform - CLI Basics

Terraform: user-data