Multi User Edits terraform Archives - For all your terraform needs https://terraformarchitect.com/tag/multi-user-edits-terraform/ Automation cannot be an afterthought (TM) Wed, 08 Mar 2023 00:48:55 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.5 Multi User Edits and Terraform State file https://terraformarchitect.com/production-terraform/multi-user-edits-and-terraform-state-file/?utm_source=rss&utm_medium=rss&utm_campaign=multi-user-edits-and-terraform-state-file https://terraformarchitect.com/production-terraform/multi-user-edits-and-terraform-state-file/#respond Wed, 30 Mar 2022 17:02:22 +0000 https://terraformarchitect.com/?p=209 What if you have users are working on the same terraform project (they don’t need to work directly on the state file)? How does the state file know which changes […]

The post Multi User Edits and Terraform State file appeared first on For all your terraform needs.

]]>
What if you have users are working on the same terraform project (they don’t need to work directly on the state file)? How does the state file know which changes were the latest – and how does it merge everyone’s changes? (i.e. prevent overwrites)

Multiple Users and Terraform State file

terraform state pull  Always use terraform state pull prior to starting work on the tf project.

Pulling the terraform state file

To ensure that you always pick up the latest terraform state, you need to perform a special operation.

Apart from doing the normal git pull it is also good to do the terraform state pull  . All latest changes within the terraform state file will be pulled with this command.

terraform state pull 

Push terraform state file?

This is a command that can potentially lead to an inconsistent state. Push might override other team member changes on to terraform state file. It is often discouraged to use terraform state push command.

terraform state push
Do not use terraform state push, as the push happens automatically when you tf apply.

Can tf prevent accidental state pushes?

1.  Lineage ID – Terraform has a safety mechanism based on a lineage ID  assigned to each state file. If you are attempting to push the terraform state file with a different lineage ID then terraform will not allow it.

2. Serial Number – Terraform also assigns a unique and higher serial number to each terraform state file.

 

The post Multi User Edits and Terraform State file appeared first on For all your terraform needs.

]]>
https://terraformarchitect.com/production-terraform/multi-user-edits-and-terraform-state-file/feed/ 0