Terraform Associate 003

Terraform Associate 003 practice questions, page 4 of 6, with answer review and explanations.

Question 16

A developer launched a VM (virtual machine) outside of the Terraform workflow and ended up with two servers with the same name. They are unsure which VM is managed with Terraform, but they do have a list of all active VM IDs. Which of the following methods could you use to determine which instance Terraform manages?

  1. Run terraform state rm on both VMs, then terraform apply to recreate the correct one that will be managed by Terraform.
  2. 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 that Terraform manages.
  3. Run a terraform apply -refresh to identify the virtual machine IDs that are already managed by Terraform.
  4. Modify the Terraform configuration to add an import block for both of the virtual machines.

Question 17

When do you need to explicitly execute Terraform in refresh-only mode?

  1. Before every terraform plan.
  2. Before every terraform apply.
  3. Before every terraform import.
  4. None of the above.

Question 18

Which method for sharing Terraform modules fulfills the following criteria: 1. Keeps the module configurations confidential within your organization. 2. Supports Terraform’s semantic version constraints. 3. Provides a browsable directory of your modules.

  1. A Git repository containing your modules.
  2. A subfolder within your workspace.
  3. HCP Terraform/Terraform Cloud private registry.
  4. Public Terraform module registry.

Question 19

Which of the following is not a way to trigger terraform destroy?

  1. Passing --destroy at the end of a plan request.
  2. Running terraform destroy from the correct directory and then typing yes when prompted in the CLI.
  3. Using the destroy command with auto-approve.

Question 20

What Terraform command always causes a state file to be updated with changes that might have been made outside of Terraform?

  1. terraform apply =lock=false
  2. terraform plan -target=state
  3. terraform plan -refresh-only
  4. terraform show -json