In a scenario where an external change is made to a resource managed by Terraform, what happens when you run terraform apply?

Prepare for the HashiCorp Terraform Associate Exam with quizzes, flashcards, and multiple-choice questions. Each question includes hints and explanations. Boost your confidence and ace your exam!

Multiple Choice

In a scenario where an external change is made to a resource managed by Terraform, what happens when you run terraform apply?

Explanation:
This tests how Terraform handles state and drift. When you run an apply, Terraform first refreshes the state to capture the actual attributes of the resources as they exist in the real environment. It then compares that refreshed state to what your configuration declares. If the external change happened to align with what the configuration intends, there’s no need to modify the resource; Terraform will simply update its state to reflect the current reality. In other words, the Load Balancer isn’t changed by apply, and the state file is updated to match what actually exists now. If there were drift that contradicted the configuration, apply would plan changes to bring the resource back in line with the code.

This tests how Terraform handles state and drift. When you run an apply, Terraform first refreshes the state to capture the actual attributes of the resources as they exist in the real environment. It then compares that refreshed state to what your configuration declares. If the external change happened to align with what the configuration intends, there’s no need to modify the resource; Terraform will simply update its state to reflect the current reality. In other words, the Load Balancer isn’t changed by apply, and the state file is updated to match what actually exists now. If there were drift that contradicted the configuration, apply would plan changes to bring the resource back in line with the code.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy