HashiCorp Certified: Terraform Associate — Question 170
A developer accidentally launched a VM (virtual machine) outside of the Terraform workflow and ended up with two servers with the same name. They don’t know which VM Terraform manages but do have a list of all active VM IDs.
Which of the following methods could you use to discover which instance Terraform manages?
Answer options
- A. Run terraform taint/code on all the VMs to recreate them
- B. Update the code to include outputs for the ID of all VMs, then run terraform plan to view the outputs
- C. Run terraform state list to find the names of all VMs, then run terraform state show for each of them to find which VM ID Terraform manages
- D. Use terraform refresh/code to find out which IDs are already part of state
Correct answer: C
Explanation
The correct answer is C because running 'terraform state list' allows you to see all resources managed by Terraform, and 'terraform state show' provides details about each resource, including the VM ID. Options A and B do not provide a direct method to identify the managed VM, while D does not clarify the specific IDs associated with the state.