Exam Terraform Associate All QuestionsBrowse all questions from this exam
Question 75

You have a simple Terraform configuration containing one virtual machine (VM) in a cloud provider. You run terraform apply and the VM is created successfully.

What will happen if you delete the VM using the cloud provider console, and run terraform apply again without changing any Terraform code?

    Correct Answer: D

    Terraform will recreate the VM. Terraform keeps track of infrastructure resources using a state file. When you delete a VM through the cloud provider's console, the VM is removed in the cloud, but the Terraform state file still believes the VM exists. When you run terraform apply, Terraform first refreshes the state by checking the actual state of resources with what is defined in the configuration. It will detect that the VM is missing and will create a new one to match the configuration specified in the Terraform code.

Discussion
vitasacOption: D

for sure response D

IpergortaOption: D

The answer is D

Tyler2023Option: D

I tried this, I created the storage account first by running terraform apply Then I manually deleted the storage account through azure portal Then reran the terraform apply - It refresh the state, which detects that the storage account was gone - Then it re-creates storage account with the same name but without the data from previous instance

chimonsOption: D

A refresh will be made before apply, therefore terraform will detect the VM is missing, and will update state accordingly. Then, it will create a new one to match configuration

robertninhoOption: D

Correct answer is D. Terraform will recreate the VM. In Terraform, the state file is used to store the current state of your infrastructure. When you run terraform apply, Terraform compares the state of your infrastructure as defined in the configuration files with the state recorded in the state file, and then makes any necessary changes to bring the infrastructure into compliance with the configuration.

lucasbgOption: C

it`s C for sure. Since the VM was deleted using the cloud web/console, the tfstate will still contain the VM information there, hence nothing will be done. This is drift, and the steps here will be to run terraform -apply | plan -refresh-only, the tfsate will update that the VM was removed and then you will run apply again.

Mridul31792

Correct answer is D as terraform apply implicitly runs terraform refresh before applying the changes which will clear the data of VM from the state file and plan will show to create a new VM.

adoubanOption: D

I have tested this on my lab on oracle cloud, 1- created a VM using TF 2- Deleted VM manually 3- on Terraform apply, attempted to recreate the instance D is the correct answer

secdaddyOption: D

Not sure how you can get C I just did this : 1. created a VM on AWS using terraform apply 2. used the AWS console to delete the VM 3. ran terraform apply again without changing any Terraform code Result : terraform recreated the VM (D)

chaoscreaterOption: D

The people who answered C are just doomed to fail this exam. This is such a basic foundational knowledge and it's the very core of Terraform and you can't even get this simple one right? This is such a freebie question.

GHOST1985Option: C

Of course C When you delete from the console you don't remove the VM from the state file so in the next plan or apply terrafom will not apply any changes because from based on the state file the VM is already created.

vibzr2023Option: D

D. Terraform will recreate the VM When you delete a resource like a VM directly through the cloud provider's console (outside of Terraform), the Terraform state file still believes the resource exists, as it's unaware of any changes made outside its management. The next time you run terraform apply, Terraform compares the desired state (defined in your Terraform configuration) with the actual state (as recorded in the state file and observed in the cloud environment). Since the actual VM no longer exists but your Terraform configuration still defines it, Terraform detects this discrepancy and takes action to reconcile the difference by creating a new VM to match the desired state defined in your Terraform configuration. Terraform's goal is always to make the real-world infrastructure match the configuration.

gofavad926Option: D

D, the instance will be recreated

HalimbOption: D

D. Stop messing around. This behavior applies to any resource created and managed by Terraform, not just virtual machines, e.g. simple resources like resource groups in Azure (like I've tested with) or any other cloud provider's resources.

Bluemoon22Option: D

answer is D

Power123Option: D

D is correct

vadeemkaaOption: D

Definitely the answer is D

Raghav_123Option: C

The ans is C