To stop Terraform from managing a specific resource while leaving the resource in place, which command would you use?

Prepare for the HashiCorp Terraform Associate Exam with quizzes, flashcards, and multiple-choice questions. Each question includes hints and explanations. Boost your confidence and ace your exam!

Multiple Choice

To stop Terraform from managing a specific resource while leaving the resource in place, which command would you use?

Explanation:
Detaching a resource from Terraform's state is how you stop Terraform from managing it while leaving the actual resource in place. You do this by removing the resource from the state file, so Terraform no longer tracks it in future plans or applies. The proper command is to run terraform state rm followed by the resource address, for example: terraform state rm aws_instance.ubuntu[1]. After this, Terraform will ignore that resource going forward, yet the AWS instance remains in your account. Other approaches shown won’t achieve this—they either try to apply changes, plan, or use a non-existent delete command. If you later want Terraform to manage it again, you’d need to re-import or recreate it in the configuration.

Detaching a resource from Terraform's state is how you stop Terraform from managing it while leaving the actual resource in place. You do this by removing the resource from the state file, so Terraform no longer tracks it in future plans or applies. The proper command is to run terraform state rm followed by the resource address, for example: terraform state rm aws_instance.ubuntu[1]. After this, Terraform will ignore that resource going forward, yet the AWS instance remains in your account. Other approaches shown won’t achieve this—they either try to apply changes, plan, or use a non-existent delete command. If you later want Terraform to manage it again, you’d need to re-import or recreate it in the configuration.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy