Collaborative IaC using Terraform

Terraform is taking over the market and since it is cloud-agnostic, you can use the same language paradigm to provision infrastructure in any cloud environment.

This is really good when you are provisioning in your local machine, but what happens when you want to let multiple developers work on the same code? One way is sharing your state file but this is not recommended as terraform state holds some critical information like passwords, IPs.

So how do we solve this?

This can be done using a terraform remote state.

Remote state:

Using a remote state you can store your state configuration file on the cloud and the same state files can be used by different developers to provision infrastructure.

In order to define the terraform remote state your need to create a file named “”, this will hold all the backend information and configuration of your terraform.

# To hold state file locks

terraform {# Use latest terraform version and always pin versionsrequired_version = "=0.13.4"backend "s3" {# To store state filesbucket = "terraform-live"key = "terraform.tfstate"region = "us-west-2"# To hold state file locksdynamodb_table = "terraform-live-locks"encrypt = true}}

Once you have it ready, you need yo created a s3 bucket named “terraform-live" and DynamoDB table named “terraform-live-locks" with key “LockID” which would hold the locks when you run terraform operations.

After this, run terraform init and you are ready to go.




DevOps / SRE Engineer. Blog: System admin turned SRE. I love Linux.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium


Top New Features Coming in Winter 18 Release

10 Legacy Cloud Considerations

PHP 在windows上的MAMP安裝Composer

How to create a DAX date table in Power BI

What PHP Test Framework should you use?

[LeetCode Walkthrough] 240. Search a 2D Matrix II

How to deploy a NuGet package + Run tests against Azurite in local & DevOps environments — Part 2/2

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
Prabesh Thapa

Prabesh Thapa

DevOps / SRE Engineer. Blog: System admin turned SRE. I love Linux.

More from Medium

Generate SSH key using terraform for multiple environments

Ansible Dynamic Inventory AWS

Getting started with Terraform

Creating a GCP Project with Terraform