Which of the following is not a way to trigger terraform destroy?
Which of the following is not a way to trigger terraform destroy?
Deleting the state file and running terraform apply will not trigger Terraform destroy. When you delete the state file, Terraform loses track of the existing infrastructure but does not destroy it. Instead, running terraform apply under these conditions would likely lead Terraform to attempt to recreate all resources based on the current configuration, potentially leading to unexpected results. This is not a method for triggering a destroy operation.
The real exam gives options either apply -destroy or delete state file + plan, so obviously plan does not destroy anything, so I went with this. The examtopics question here is misspelled. So you won’t be confused that much on real exam.
I'd go with D. The `terraform plan -destroy` command will only show what is going to be destroyed (it’s only a plan). However, removing the state file has nothing to do with `terraform destroy` at all - it would only make Terraform forget about its objects while they continue to exist in the remote system.
I tested in a lab. When you run "terraform plan -destroy" it just shows which resource will be destroyed but didnt destroy anything. If you want to destroy you should run "terraform destroy". But interestingly When you delete state file and run "terraform apply" command it creates a new resources not destroy. It seems two options are correct. C and D.
D. C: Wrong. "Destroy mode: creates a plan whose goal is to destroy all remote objects that currently exist, leaving an empty Terraform state. It is the same as running terraform destroy." https://developer.hashicorp.com/terraform/cli/commands/plan#planning-modes
C. Passing --destroy at the end of a plan request. The terraform destroy command is used to destroy the infrastructure resources created by Terraform according to the current configuration. Option D is incorrect because deleting the state file and running terraform apply will not trigger terraform destroy. Running terraform apply with no changes to the Terraform configuration will have no effect on the existing infrastructure resources, and will not destroy them. If you delete the state file and then run terraform apply, Terraform will not know about any existing infrastructure resources, and will attempt to create new resources according to the current configuration. This may lead to unexpected results and is not a recommended approach to managing infrastructure with Terraform.
option D is correct answer
Plan don’t destroy anything
execute plan doesn't trigger destroy
will go for D
"is not a way to do " - ill take A.. you shouldn't do destroy without being sure what you are destroying..
Because there is no double-dash destroy (hoping this isn’t a typo)
Destroy mode: creates a plan whose goal is to destroy all remote objects that currently exist, leaving an empty Terraform state. It is the same as running terraform destroy. Destroy mode can be useful for situations like transient development environments, where the managed objects cease to be useful once the development task is complete. Activate destroy mode using the -destroy command line option.
delete state file is never suggested by terraform so simple, answer is D.
Answer is C because there is no such command to trigger a destroy "terrafrom destroy --destroy" A & B are way to trigger a destroy. D: will not suite because in the question it has mentioned that "way of triggering a destroy" instead of "way of destroy"
im going with D
D, if you delete the state file, then run terraform apply, terraform will try to create the whole infrastructure but get error.
D makes more sense than C. Correct answer should be D