nerdexam
HashiCorp

TA-002-P · Question #241

You wanted to destroy some of the dependent resources from real infrastructure. You choose to delete those resources from your configuration file and run terraform plan and then apply. Which of the…

The correct answer is A. Terraform can still determine the correct order for destruction from the state even when. Terraform's state file records all managed resources and their dependency relationships. When you remove resources from your configuration and run 'terraform apply', Terraform compares the desired state (config) against the current state (state file), identifies resources to…

Implement and maintain state

Question

You wanted to destroy some of the dependent resources from real infrastructure. You choose to delete those resources from your configuration file and run terraform plan and then apply. Which of the following way your resources would be destroyed?

Options

  • ATerraform can still determine the correct order for destruction from the state even when
  • BThose would be destroyed in the order in which they were written in the configuration file
  • CThe resource will be destructed in random order as you have already deleted them from
  • DYou can not destroy resources by deleting them from configuration file and running plan

How the community answered

(57 responses)
  • A
    88% (50)
  • B
    4% (2)
  • C
    2% (1)
  • D
    7% (4)

Explanation

Terraform's state file records all managed resources and their dependency relationships. When you remove resources from your configuration and run 'terraform apply', Terraform compares the desired state (config) against the current state (state file), identifies resources to destroy, and uses the dependency graph stored in state to determine the correct destruction order - destroying dependents before their dependencies, even without the config present.

Topics

#Terraform State#Resource Destruction#Dependency Resolution#Configuration Management

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice