0
0
Terraformcloud~5 mins

Backend initialization and migration in Terraform - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of Terraform backend initialization?
Backend initialization configures where Terraform stores its state files, enabling collaboration and state locking to prevent conflicts.
Click to reveal answer
beginner
What command do you use to initialize a Terraform backend?
You use terraform init to initialize the backend and prepare the working directory for Terraform operations.
Click to reveal answer
intermediate
Why would you migrate a Terraform backend?
To move the Terraform state from one backend to another, for example, from local files to a remote storage for better collaboration and security.
Click to reveal answer
intermediate
What is the command to migrate Terraform state to a new backend?
Run terraform init -migrate-state to migrate the existing state to the newly configured backend safely.
Click to reveal answer
advanced
What happens if you change backend configuration without migrating state?
Terraform will not automatically move your state, which can cause errors or loss of state tracking. You must migrate state explicitly.
Click to reveal answer
Which command initializes the Terraform backend?
Aterraform init
Bterraform apply
Cterraform plan
Dterraform migrate
What does the -migrate-state flag do during terraform init?
AValidates the Terraform configuration
BDeletes the existing state
CCreates a new state file locally
DMoves state to the new backend
Why is backend migration important?
ATo change where state is stored for collaboration
BTo speed up Terraform plan
CTo delete old infrastructure
DTo update Terraform version
What happens if you change backend config but skip migration?
ATerraform automatically migrates state
BTerraform loses track of existing resources
CTerraform throws an error or uses empty state
DTerraform deletes all resources
Which backend type is commonly used for remote state storage in Terraform?
ALocal file
BS3 bucket
CDocker container
DKubernetes pod
Explain the steps to migrate Terraform state from a local backend to a remote backend.
Think about changing config and using terraform init carefully.
You got /4 concepts.
    Describe why backend initialization is critical before running Terraform commands.
    Consider what happens if Terraform doesn't know where to save its progress.
    You got /4 concepts.