0
0
Terraformcloud~5 mins

Terraform state list command - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the terraform state list command do?
It shows all the resources currently tracked in the Terraform state file. Think of it like a list of all items Terraform knows about in your infrastructure.
Click to reveal answer
beginner
Why is the Terraform state important?
The state keeps track of what Terraform has created or changed. It helps Terraform know what to update or delete next time you run it.
Click to reveal answer
intermediate
How can you use terraform state list to find a specific resource?
You can add a filter after the command, like terraform state list aws_instance.myserver, to see if that resource exists in the state.
Click to reveal answer
intermediate
What happens if the Terraform state file is missing or corrupted?
Terraform won’t know what resources it manages, which can cause errors or duplicate resources. Always keep backups of your state file.
Click to reveal answer
intermediate
Can terraform state list show resources from multiple workspaces?
No, it only shows resources from the current workspace’s state. You need to switch workspaces to see their states.
Click to reveal answer
What does terraform state list display?
AAll available Terraform commands
BAll resources tracked in the current Terraform state
CThe current Terraform version
DThe list of Terraform providers
How can you filter the output of terraform state list?
ABy editing the state file manually
BBy using the <code>--filter</code> flag
CBy running <code>terraform plan</code>
DBy adding a resource name or type after the command
If the state file is missing, what will happen when you run Terraform?
ATerraform will create all resources again
BTerraform will delete all resources
CTerraform will show an error and stop
DTerraform will ignore the missing state and continue
Does terraform state list show resources from all workspaces at once?
ANo, only from the current workspace
BYes, it shows all workspaces combined
COnly from the default workspace
DOnly from remote backends
Why should you keep backups of your Terraform state file?
ATo prevent loss of resource tracking and avoid errors
BTo speed up Terraform commands
CTo share with other teams
DTo reduce cloud costs
Explain what the terraform state list command does and why it is useful.
Think about how Terraform keeps track of what it manages.
You got /3 concepts.
    Describe what could happen if the Terraform state file is lost or corrupted.
    Consider Terraform’s need to know what it already created.
    You got /3 concepts.