Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 20


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.)

Show Answer
Correct Answer: B,C,D

To manage existing VMs on Google Cloud Platform using Terraform, you need to follow two crucial steps. First, you should use the 'terraform import' command to import the existing VMs into Terraform's state file. This step allows Terraform to recognize and manage those resources. Second, you must write Terraform configuration that describes the current state of these VMs. This configuration allows Terraform to maintain and update the VMs as needed in the future. Provisioning new VMs with the same names would create duplicates and potential conflicts, and there is no 'terraform import-gcp' command in Terraform.

Discussion

17 comments
Sign in to comment
tipzzzOptions: BC
Apr 24, 2022

BC for sure

fabiomlopOptions: BC
Jun 18, 2022

You should create the equivalent configuration first, and then run import to load it on the state file.

AzRNoobOptions: BC
Apr 7, 2023

BC are the correct options: B. Use the terraform import command for the existing VMs. This command allows you to import existing infrastructure into your Terraform state file so that Terraform can manage it. You will need to provide the resource type and name, along with any required attributes, for each VM you want to import. C. Write Terraform configuration for the existing VMs. Once the VMs have been imported into the Terraform state file, you will need to write configuration code that describes the desired state of the VMs. This will typically involve creating a new Terraform module or modifying an existing one to include the imported resources. Option A is incorrect because provisioning new VMs with the same names would create duplicate resources and could cause conflicts with the existing VMs. Option D is also incorrect because there is no terraform import-gcp command in Terraform. The correct command for importing GCP resources is simply terraform import.

Tyler2023Options: BC
Oct 21, 2023

There are two ways to manage existing resource using Terraform You can use 'terraform import' or you can use the import block So answers are: B. Use the terraform import command for the existing VMs Most Voted C. Write Terraform configuration for the existing VMs https://developer.hashicorp.com/terraform/cli/import/usage https://developer.hashicorp.com/terraform/language/import

Ni33Options: BC
May 8, 2023

B&C are correct

Busi57Options: BC
Jul 23, 2023

i choose BC

JayanthOptions: BC
Jul 28, 2023

B. Use the terraform import command for the existing VMs C. Write Terraform configuration for the existing VMs

enookOptions: BC
Jan 3, 2024

BCBCBCBCBCBC

kingfighers
Apr 1, 2024

there is no 'import-gcp' in terraform official doc

acheironOptions: BC
Mar 16, 2023

Write configuration then import the existing infrastructure.

Power123Options: BC
Mar 30, 2023

B,C - first write the configuration and then import

connecttozeeOptions: BC
Apr 3, 2023

BC is correct https://developer.hashicorp.com/terraform/tutorials/state/state-import

karendavtyanOptions: BC
May 5, 2023

B.True C. True

milan92stankovicOptions: BC
Jun 14, 2023

Write configuration and import.

Shane_COptions: BC
Jul 4, 2023

BC are the correct answers here

Busi57Options: BC
Jul 23, 2023

i choose BC

doodlearmyOptions: BC
Jul 5, 2024

there is no 'import-gcp' in terraform official doc