DEV Community

Rahul Wagh
Rahul Wagh

Posted on

Terraform state locking using DynamoDB(LockID) and S3 Bucket

Terraform state locking is really important when you work in a team where multiple developers are trying to update the same Terraform state file.

It prevents Terraform state file(terraform.tfstate) from accidental updates by putting a lock on the file so that the current update can be finished before processing the new change. The feature of Terraform state locking is supported by AWS S3 and Dynamo DB(LockID).

In this lab session, we will be looking into -

  1. How to Store Terraform state file remotely on S3?
  2. Create DynamoDB table with LockID as Key
  3. Simulate the terraform state locking by creating multiple terraform projects using the same Terraform state file.

Discussion (0)