Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 279


A senior admin accidentally deleted some of your cloud instances. What does Terraform do when you run terraform apply?

Show Answer
Correct Answer: C

When Terraform runs 'terraform apply' after instances have been accidentally deleted, it compares the current state with the desired state defined in your configuration files. Terraform will then act to bring the infrastructure back to the desired state by rebuilding only the instances that were deleted. This ensures that the infrastructure matches the configuration specified, which is a fundamental feature of Terraform's state management and desired state reconciliation.

Discussion

2 comments
Sign in to comment
Pete987Option: C
Aug 23, 2023

C. Rebuild only the instances that were deleted When you run terraform apply after some instances have been accidentally deleted by a senior admin, Terraform will detect the differences between your desired configuration (defined in your Terraform files) and the actual state of your cloud infrastructure (as recorded in the Terraform state file). It will then take the necessary actions to reconcile the two. In this case, Terraform will identify that the instances were deleted and no longer exist in the state file. It will then create new instances to match the desired configuration, effectively rebuilding only the instances that were deleted. This approach is one of the key benefits of using Terraform: it helps maintain the desired infrastructure state even when changes occur outside of Terraform's control.

heelocoOption: C
Sep 21, 2023

agree Pete987