Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam Terraform Associate topic 1 question 20 discussion

Actual exam question from HashiCorp's Terraform Associate
Question #: 20
Topic #: 1
[All Terraform Associate Questions]

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

  • A. Provision new VMs using Terraform with the same VM names
  • B. Use the terraform import command for the existing VMs
  • C. Write Terraform configuration for the existing VMs
  • D. Run the terraform import-gcp command
Show Suggested Answer Hide Answer
Suggested Answer: BD 🗳️
The terraform import command is used to import existing infrastructure.
Import existing Google Cloud resources into Terraform with Terraformer.
Reference:
https://www.terraform.io/docs/cli/import/usage.html
https://cloud.google.com/docs/terraform

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
tipzzz
Highly Voted 2 years ago
BC for sure
upvoted 30 times
...
fabiomlop
Highly Voted 1 year, 10 months ago
Selected Answer: BC
You should create the equivalent configuration first, and then run import to load it on the state file.
upvoted 17 times
...
kingfighers
Most Recent 1 month ago
there is no 'import-gcp' in terraform official doc
upvoted 2 times
...
enook
4 months ago
Selected Answer: BC
BCBCBCBCBCBC
upvoted 2 times
...
Tyler2023
6 months, 2 weeks ago
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
upvoted 2 times
...
Jayanth
9 months, 1 week ago
B. Use the terraform import command for the existing VMs C. Write Terraform configuration for the existing VMs
upvoted 2 times
...
Busi57
9 months, 2 weeks ago
Selected Answer: BC
i choose BC
upvoted 1 times
...
Busi57
9 months, 2 weeks ago
i choose BC
upvoted 2 times
...
Shane_C
10 months ago
Selected Answer: BC
BC are the correct answers here
upvoted 1 times
...
milan92stankovic
10 months, 3 weeks ago
Selected Answer: BC
Write configuration and import.
upvoted 1 times
...
Ni33
12 months ago
Selected Answer: BC
B&C are correct
upvoted 2 times
...
karendavtyan
1 year ago
Selected Answer: BC
B.True C. True
upvoted 1 times
...
AzRNoob
1 year ago
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.
upvoted 9 times
...
connecttozee
1 year, 1 month ago
BC is correct https://developer.hashicorp.com/terraform/tutorials/state/state-import
upvoted 1 times
...
Power123
1 year, 1 month ago
B,C - first write the configuration and then import
upvoted 1 times
...
acheiron
1 year, 1 month ago
Selected Answer: BC
Write configuration then import the existing infrastructure.
upvoted 1 times
...
gargaditya
1 year, 1 month ago
Selected Answer: BC
Terraform is able to import existing infrastructure. This allows you take resources you've created by some other means and bring it under Terraform management. The 2 main logical steps are as shown in diagram: https://drive.google.com/file/d/1tgbhHr1vHJMbsWJjOtearL-iCus064Ya/view?usp=sharing I. Use terraform import command to import the existing config INTO TFSTATE II. Manually write actual configuration(.tf) files to reflect how the .tfstate(infra) would be achieved
upvoted 1 times
gargaditya
1 year, 1 month ago
===== Detailed procedure/approach: I. Manually write actual configuration(.tf) files to reflect how the .tfstate(infra) would be achieved resource “aws_instance” “web”{ } You can leave the body of the resource block blank for now and return to fill it in once the instance is imported. II. Use terraform import command to import the existing config INTO TFSTATE(and link to above resource) terraform import aws_instance.web <actual instance id in AWS> III. Now compare the imported tfstate file with config file(.tf) and fill relevant sections with information. IV. Run terraform plan to make sure no changes indicated(which means config file accurately reflects state file).
upvoted 1 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...