Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 199


Terraform destroy is the only way to remove infrastructure.

Show Answer
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

5 comments
Sign in to comment
Basavaraju_VOption: B
Mar 9, 2023

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

PietjeplukgelukOption: B
Feb 14, 2023

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

nakikooOption: B
Jan 13, 2023

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
Jul 25, 2023

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

ArizonaClassicsOption: B
Jan 13, 2023

B for Sure

ramzez4815Option: B
Oct 25, 2023

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