0
0
Terraformcloud~5 mins

Terraform state pull and push - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the terraform state pull command do?
It downloads the current Terraform state file from the remote backend and outputs it locally. This lets you see the exact state Terraform is tracking.
Click to reveal answer
beginner
What is the purpose of terraform state push?
It uploads a local Terraform state file to the remote backend, replacing the existing state. This is useful to fix or update the remote state manually.
Click to reveal answer
intermediate
Why should you be careful when using terraform state push?
Because it overwrites the remote state file, which can cause conflicts or loss of changes if done incorrectly. Always ensure the state file is valid and up to date.
Click to reveal answer
beginner
How does Terraform use the state file during deployments?
Terraform uses the state file to track resources it manages. It compares the state to your configuration to know what to create, update, or delete.
Click to reveal answer
intermediate
When might you need to manually pull and push Terraform state?
When fixing state corruption, migrating state between backends, or recovering from errors where the remote state is out of sync with local files.
Click to reveal answer
What does terraform state pull do?
ADownloads the current remote state file
BUploads a local state file to remote
CDeletes the remote state file
DInitializes the Terraform backend
Which command uploads a local state file to the remote backend?
Aterraform state pull
Bterraform apply
Cterraform init
Dterraform state push
Why should you avoid frequent use of terraform state push?
AIt can overwrite remote state causing conflicts
BIt deletes all resources
CIt resets your Terraform configuration
DIt only works with local backends
What is stored inside the Terraform state file?
ATerraform configuration code
BResource metadata and current infrastructure info
CUser credentials
DCloud provider billing info
When is it appropriate to manually pull and push Terraform state?
AWhen creating new resources
BEvery time you run <code>terraform apply</code>
CWhen fixing state corruption or migrating state
DWhen deleting Terraform configuration files
Explain the roles of terraform state pull and terraform state push in managing Terraform state.
Think about how Terraform keeps track of resources remotely and locally.
You got /4 concepts.
    Describe why careful handling of Terraform state files is important during infrastructure management.
    Consider what happens if Terraform's view of resources is wrong.
    You got /4 concepts.