Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam Terraform Associate topic 1 question 142 discussion

Actual exam question from HashiCorp's Terraform Associate
Question #: 142
Topic #: 1
[All Terraform Associate Questions]

Which of the following is not a way to trigger terraform destroy?

  • A. Using the destroy command with auto-approve
  • B. Running terraform destroy from the correct directory and then typing "yes" when prompted in the CLI
  • C. Passing --destroy at the end of a plan request
  • D. Delete the state file and run terraform apply
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
lizzard812
Highly Voted 1 year ago
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.
upvoted 15 times
...
wanrltw
Highly Voted 1 year, 4 months ago
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.
upvoted 13 times
...
SilentH
Most Recent 1 week, 1 day ago
Selected Answer: C
Because there is no double-dash destroy (hoping this isn’t a typo)
upvoted 1 times
...
Ryan1002
1 month ago
Selected Answer: D
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.
upvoted 1 times
...
recep38
2 months ago
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.
upvoted 2 times
...
vipulchoubisa
3 months, 2 weeks ago
delete state file is never suggested by terraform so simple, answer is D.
upvoted 1 times
...
samimshaikh
3 months, 4 weeks ago
Selected Answer: C
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"
upvoted 1 times
...
March2023
10 months, 2 weeks ago
Selected Answer: D
im going with D
upvoted 1 times
...
sdm13168
11 months, 1 week ago
Selected Answer: D
D, if you delete the state file, then run terraform apply, terraform will try to create the whole infrastructure but get error.
upvoted 1 times
...
FawadK
11 months, 3 weeks ago
Selected Answer: D
D makes more sense than C. Correct answer should be D
upvoted 1 times
...
zanhsieh
11 months, 3 weeks ago
Selected Answer: 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
upvoted 2 times
...
camps
1 year ago
Selected Answer: C
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.
upvoted 2 times
...
SilentMilli
1 year, 1 month ago
Selected Answer: D
terraform apply is a command that creates or updates resources as described in the Terraform configuration. Deleting the state file and running terraform apply will cause Terraform to create resources that are missing, rather than destroying them.
upvoted 1 times
...
Manguu
1 year, 1 month ago
Selected Answer: D
D. This will not trigger a destroy, your old resources are no longer managed by TF
upvoted 1 times
...
pyro7
1 year, 2 months ago
D. Delete the state file and run terraform apply is not a way to trigger terraform destroy. The other options listed are valid ways to trigger the terraform destroy command: A. Using the terraform destroy command with the auto-approve option: terraform destroy -auto-approve B. Running terraform destroy from the correct directory and then typing "yes" when prompted in the CLI: terraform destroy followed by typing "yes" C. Passing --destroy at the end of a plan request: terraform plan --destroy However, deleting the state file and running terraform apply is not a correct way to trigger terraform destroy. terraform apply is used to create or update infrastructure resources, whereas terraform destroy is used to destroy resources. If the state file is deleted and terraform apply is run, it will create resources instead of destroying them.
upvoted 2 times
...
Arrash
1 year, 2 months ago
Usage: terraform destroy [options] This command is just a convenience alias for the following command: terraform apply -destroy
upvoted 1 times
...
agmesas
1 year, 2 months ago
A y B are correct. C is not a way to run a destroy because it only show the plan. D is not related with a destroy so D is true too. C is the correct answer
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...