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

You have a Terraform configuration that defines a single virtual machine with no references to it. You have run terraform apply to create the resource, and then removed the resource definition from your Terraform configuration file.

What will happen when you run terraform apply in the working directory again?

    Correct Answer: B

    When a resource is defined in a Terraform configuration and is subsequently removed from the configuration file, running 'terraform apply' will cause Terraform to align the real infrastructure with the current state of the configuration file. Since the configuration no longer includes the resource, Terraform will recognize that the resource should no longer exist and will destroy it.

Discussion
depal_dhirOption: B

This will destroy the VM

keiffo2Option: B

If you remove the resource from your config file and the resource is in your state file, terraform will apply the configuration in the config file - which is to delete the resource

Nick_001Option: B

tested in lab. When reference to resource is removed in config file the next "terraform apply" will destroy the resource. Below is the output from cli # aws_instance.name will be destroyed # (because aws_instance.name is not in configuration)

dokaeduOption: D

The question is saying removing resource definition of the resource, NOT removing the resource (VM)

dokaeduOption: D

The question is saying removing the description of the resource, NOT removing the resource (VM)

dnscloud02

definition not description