NS0-403 practice question 13 of 15

You used a Terraform configuration to create a number of resources in Google Cloud for testing your applications. You have completed the tests and you no longer need the infrastructure. You want to delete all of the resources and save costs. In this scenario, which command would you use to satisfy the requirements?

Full set: 60 questions
Answer options
A: terraform untaint
B: terraform apply
C: terraform force—unlock
D: terraform destroy Correct answer
Correct Answer:
D. terraform destroy
Explanation

The terraform destroy command is used to de-provision and delete all infrastructure resources managed by a specific Terraform configuration. It reads the current state file to identify all created resources and then generates a plan to destroy them. After user confirmation, it proceeds with the deletion, which is ideal for cleaning up temporary environments like the one described in the scenario to prevent ongoing costs.

Why Incorrect

A. terraform untaint: This command removes the "tainted" status from a resource, preventing it from being destroyed and recreated on the next apply. It does not delete infrastructure.
B. terraform apply: This command creates or updates infrastructure to match the configuration files. It only destroys resources that have been removed from the configuration, not the entire environment.
C. terraform force—unlock: This is a state management command used to manually unlock a state file that was left locked by a failed operation. It does not affect the infrastructure resources.

References

1. HashiCorp Terraform Documentation, "destroy Command": "The terraform destroy command is a convenient way to destroy all remote objects managed by a particular Terraform configuration." This command is the standard and intended method for tearing down infrastructure.

Source: HashiCorp, Terraform CLI Documentation, destroy command. Available at: https://developer.hashicorp.com/terraform/cli/commands/destroy

2. NetApp Documentation, "Deploy Cloud Volumes ONTAP in Google Cloud": In the section on cleaning up the environment, the official procedure states: "When you no longer need the Cloud Volumes ONTAP system, you should destroy the environment to avoid incurring additional charges... Run the terraform destroy command from the working directory where you have your Terraform files."

Source: NetApp Product Documentation, "Clean up the environment" section. Available at: https://docs.netapp.com/us-en/cloud-manager-automation/taskdeploycvogcpterraform.html#clean-up-the-environment

3. HashiCorp Terraform Documentation, "apply Command": "The terraform apply command executes the actions proposed in a Terraform plan to create, update, or destroy infrastructure." While it can destroy, its primary function is to reconcile the configuration with the deployed state, not to perform a full teardown.

Source: HashiCorp, Terraform CLI Documentation, apply command. Available at: https://developer.hashicorp.com/terraform/cli/commands/apply

Scroll to Top