You have provisioned some virtual machines (VMs) on Google Cloud Platform (GCP) using the gcloud command line tool. However, you are standardizing with Terraform and want to manage these VMs using Terraform instead.
What are the two things you must do to achieve this? Choose two correct answers.
- Run the terraform Import-gcp command
- Write Terraform configuration for the existing VMs
- Use the terraform import command for the existing VMs
- Provision new VMs using Terraform with the same VM names
Answer(s): B,C
Explanation:
To import existing resources into Terraform, you need to do two things1:
Write a resource configuration block for each resource, matching the type and name used in your state file.
Run terraform import for each resource, specifying its address and ID. There is no such command as terraform Import-gcp, and provisioning new VMs with the same names will not import them into Terraform.
Reveal Solution Next Question