HashiCorp Certified: Terraform Associate — Question 194
A developer on your team is going to tear down an existing deployment managed by Terraform and deploy a new one. However, there is a server resource named aws_instance.ubuntu[1] they would like to keep. What command should they use to tell Terraform to stop managing that specific resource?
Answer options
- A. terraform destroy aws_instance.ubuntu[l]
- B. terraform apply rm aws_instance.ubuntu[l]
- C. terraform state rm aws_instance.ubuntu[l]
- D. terraform plan rm aws_instance.ubuntu[l]
Correct answer: C
Explanation
The correct command is 'terraform state rm aws_instance.ubuntu[1]', which removes the specified resource from Terraform's state file, allowing it to be retained without being destroyed. The other options either attempt to destroy the resource or incorrectly apply changes without properly removing the resource from state management.