Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 246


When should you write Terraform configuration files for existing infrastructure that you want to start managing with Terraform?

Show Answer
Correct Answer: A

To import existing infrastructure into Terraform, you must first write the corresponding Terraform resource block in your configuration files. This block establishes how the resource will be known and managed in Terraform. Once the configuration is written, you can then use the terraform import command to associate the existing resource with this configuration. Terraform does not automatically generate configuration files for existing resources, hence it is essential to create these files beforehand.

Discussion

17 comments
Sign in to comment
Ni33Option: A
May 12, 2023

A is the correct answer !

MarshalLawOption: D
May 9, 2023

D: You can use the import command to migrate existing resources into your Terraform state file. The import command does not currently generate the configuration for the imported resource, so you must write the corresponding configuration block to map the imported resource to it. Importing infrastructure involves five steps: 1 Identify the existing infrastructure you will import. 2 Import infrastructure into your Terraform state file. 3 Write Terraform configuration that matches that infrastructure. 4 Review the Terraform plan to ensure the configuration matches the expected state and infrastructure. 5 Apply the configuration to update your Terraform state. Source: https://developer.hashicorp.com/terraform/tutorials/state/state-import

[Removed]
Jul 3, 2023

Answer is A. Source: https://developer.hashicorp.com/terraform/tutorials/state/state-import. Has been updated with new steps for Terraform v1.5 Using configuration to import resources involves the following steps: Identify the existing infrastructure you will import. Define an import block for the resources. Run terraform plan to review the import plan and optionally generate configuration for the resources. Prune generated configuration to only the required arguments. Apply the configuration to bring the resource into your Terraform state file.

joyboy23
Jul 7, 2023

But that is your "Import config", It is not the "existing infra config"

Oleg_golOption: D
May 6, 2023

D. After you run terraform import

dbrosowskiCWOption: A
May 8, 2023

A: You need to have the corresponding resources defined in your Terraform configuration files before you can import them.

SathisgmOption: D
May 9, 2023

Answer is D

sdm13168Option: A
May 15, 2023

https://spacelift.io/blog/importing-exisiting-infrastructure-into-terraform

Foram31Option: D
Jun 18, 2023

1. Run terraform import to bring the existing resources under Terraform management. This command allows you to import the existing resources into the Terraform state without the corresponding Terraform configuration files. 2.After importing the resources, you should write the Terraform configuration files to define and manage the imported resources. These configuration files specify the desired state of the infrastructure and allow you to make changes to it in a controlled manner.

lukacs16Option: A
Jul 11, 2023

"To import a resource, first write a resource block for it in your configuration, establishing the name by which it will be known to Terraform" Answer is A. https://developer.hashicorp.com/terraform/cli/import/usage

seifsklOption: A
Jul 24, 2023

Please refer to this link https://developer.hashicorp.com/terraform/cli/import/usage It is said: "To import a resource, first write a resource block for it in your configuration, establishing the name by which it will be known to Terraform ... Now terraform import can be run to attach an existing instance to this resource configuration"

arunrkaushikOption: A
Aug 13, 2023

You cannot import the resource unless the resource's basic block is not coded in the .tf file. Hence this is the 1st step. Once a basic block is written, you import the resources and enhance the code using the state details. <b> Before you run terraform import </b>

Blitz123Option: B
Jan 31, 2024

as per terraform 1.0 which is the latest version for exam its B. You can import infrastructure without corresponding Terraform code

Sydurrahman12
May 19, 2023

which one right A or D?

yubacOption: A
May 30, 2023

Condidering and existing infrastructurre on a cloud provider, in order to manage these resources on terraform you need: 1. foreach resource, add at least the resources definition using resource_type.resource_name {} 2. foreach resource, use terraform import resource_type.resource_name <id>

AdriBFKOption: A
Sep 15, 2023

Tested

uaxOption: A
Oct 28, 2023

When should you write Terraform configuration files for existing infrastructure that you want to start managing with Terraform? A. Before you run terraform import.

TricejerOption: A
Jan 31, 2024

A is correct

blop213Option: A
Apr 30, 2024

If D is right then B is necesarry right, and since its not multiple choice, it can only be A Right answer : A