nerdexam
HashiCorpHashiCorp

TA-002-P · Question #447

TA-002-P Question #447: Real Exam Question with Answer & Explanation

The correct answer is B: Terraform will prompt you to confirm that you want to destroy all the infrastructure. Running terraform destroy without flags targets all resources managed by the current configuration and requires interactive confirmation before any deletion occurs.

Use the Terraform CLI (terraform plan, apply, destroy, fmt, init, validate, workspace, import, taint, providers, output)

Question

You have created a main.tr Terraform configuration consisting of an application server, a database, and a load balancer. You ran terraform apply and all resources were created successfully. Now you realize that you do not actually need the load balancer so you run terraform destroy without any flags What will happen?

Options

  • ATerraform will destroy the application server because it is listed first in the code
  • BTerraform will prompt you to confirm that you want to destroy all the infrastructure
  • CTerraform will destroy the main.tf file
  • DTerraform will prompt you to pick which resource you want to destroy
  • ETerraform will immediately destroy all the infrastructure

Explanation

Running terraform destroy without flags targets all resources managed by the current configuration and requires interactive confirmation before any deletion occurs.

Common mistakes.

  • A. Terraform determines the destruction order based on the dependency graph between resources, not the order they appear in the source code files.
  • C. terraform destroy only removes the real infrastructure resources tracked in the state file; it never deletes local .tf configuration files.
  • D. Without a -target flag, terraform destroy does not let you select individual resources - it plans destruction of all managed resources and only prompts for a single yes/no confirmation.
  • E. Terraform does not immediately destroy anything; it always generates a plan and waits for explicit confirmation unless the -auto-approve flag is passed.

Concept tested. Terraform destroy command behavior and confirmation prompt

Reference. https://developer.hashicorp.com/terraform/cli/commands/destroy

Topics

#Terraform CLI#terraform destroy#Resource lifecycle#Confirmation prompts

Community Discussion

No community discussion yet for this question.

Full TA-002-P PracticeBrowse All TA-002-P Questions