Exam Terraform Associate All QuestionsBrowse all questions from this exam
Question 199

Terraform destroy is the only way to remove infrastructure.

    Correct Answer: B

    Terraform destroy is not the only way to remove infrastructure. Resources can also be removed by deleting or commenting out the resource block in the configuration file and then running terraform apply. This will instruct Terraform to remove the resources that are no longer defined in the configuration.

Discussion
Basavaraju_VOption: B

B. by commenting the resource block in the configuration file will also destroy the resources

PietjeplukgelukOption: B

"terraform apply -destroy" would be an alias for "terraform destroy" B for sure

ramzez4815Option: B

False: the primary way to delete infrastructure managed by Terraform is to remove the corresponding declarations from your configuration and run terraform apply. terraform destroy (or, equivalently, terraform apply -destroy) is for the less common situation where you want to destroy everything managed by a particular configuration, which is not an everyday operation for long-lived infrastructure but can be useful for short-lived infrastructure such as one-time testing environments. https://discuss.hashicorp.com/t/is-terraform-destroy-the-only-way/36619/4

ArizonaClassicsOption: B

B for Sure

nakikooOption: B

correct, you can also remove the resource definition in the state file if you previously stated it, it will detect the resource definition is absent and will delete the resource Unless you state the resource, but someone delete it manually, it will recreate it

JohnGasp

if you remove just from state, terrafrom will forgot about resource and just create new one on next apply, so first instance will not be deleted