Recall & Review
beginner
What does the
terraform state rm command do?It removes a resource from Terraform's state file without deleting the actual resource in the cloud or infrastructure.
Click to reveal answer
intermediate
Why would you use
terraform state rm instead of terraform destroy?Because
terraform state rm only removes the resource from Terraform's tracking, leaving the resource intact, while terraform destroy deletes the resource from the infrastructure.Click to reveal answer
beginner
What is a common use case for
terraform state rm?When a resource is deleted manually outside Terraform, and you want to remove it from the state file to avoid errors during future Terraform runs.
Click to reveal answer
beginner
How do you specify which resource to remove using
terraform state rm?You provide the resource address, like
terraform state rm aws_instance.example, where aws_instance.example is the resource address in the state.Click to reveal answer
intermediate
What should you be careful about when using
terraform state rm?Removing a resource from state means Terraform no longer manages it, so changes or deletions to that resource won't be tracked or applied by Terraform.
Click to reveal answer
What happens to the actual cloud resource when you run
terraform state rm?✗ Incorrect
terraform state rm only removes the resource from Terraform's state file. The actual resource in the cloud stays untouched.
Which command would you use to delete a resource both from Terraform and the cloud?
✗ Incorrect
terraform destroy deletes the resource from both Terraform state and the cloud infrastructure.
If a resource was deleted manually outside Terraform, what should you do to avoid errors in Terraform runs?
✗ Incorrect
Removing the resource from the state with terraform state rm prevents Terraform from trying to manage a resource that no longer exists.
How do you specify the resource to remove in
terraform state rm?✗ Incorrect
You must specify the exact resource address as known to Terraform, such as aws_instance.example.
What is a risk of using
terraform state rm carelessly?✗ Incorrect
Removing a resource from state means Terraform no longer manages it, so changes won't be tracked or applied.
Explain what
terraform state rm does and when you would use it.Think about managing Terraform's knowledge of resources versus the actual resources.
You got /4 concepts.
Describe the difference between
terraform state rm and terraform destroy.One affects Terraform's tracking, the other affects the real resource.
You got /4 concepts.