0
0
Terraformcloud~5 mins

Local state behavior in Terraform - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the local state file in Terraform?
The local state file keeps track of the resources Terraform manages. It helps Terraform know what exists so it can update or delete resources correctly.
Click to reveal answer
beginner
Where is the Terraform local state file usually stored?
By default, the local state file is stored in the same folder as your Terraform configuration files, named terraform.tfstate.
Click to reveal answer
intermediate
What happens if the local state file is deleted or lost?
Terraform loses track of the resources it manages. It may try to recreate resources or fail to update existing ones, causing inconsistencies.
Click to reveal answer
intermediate
How can you protect your Terraform local state file from being lost or corrupted?
You can back it up regularly or use remote state storage like Terraform Cloud or S3 to keep the state safe and share it among team members.
Click to reveal answer
intermediate
Why is local state not recommended for team environments?
Because local state is stored on one machine, it can cause conflicts if multiple people change infrastructure at the same time. Remote state helps avoid this.
Click to reveal answer
What file does Terraform use by default to store local state?
Aoutputs.tf
Bmain.tf
Cvariables.tf
Dterraform.tfstate
What is a risk of using local state in Terraform?
AState file can be lost or corrupted
BTerraform cannot create resources
CTerraform runs slower
DResources are automatically deleted
Why might teams prefer remote state over local state?
ATo avoid conflicts and share state safely
BBecause local state is slower
CRemote state files are smaller
DLocal state cannot store outputs
If you delete the local state file, what will Terraform do on next apply?
ADo nothing
BTry to recreate all resources
CAutomatically restore the state
DOnly update existing resources
Where is the local state file stored by default?
AIn a database
BIn the cloud provider
CIn the same folder as Terraform configs
DIn a hidden system folder
Explain what the Terraform local state file is and why it is important.
Think about how Terraform remembers what it created.
You got /4 concepts.
    Describe the risks of using local state in a team and how to mitigate them.
    Consider what happens when multiple people work on the same infrastructure.
    You got /4 concepts.