Exam Terraform Associate All QuestionsBrowse all questions from this exam
Question 181

When should Terraform configuration files be written when running terraform import on existing infrastructure?

    Correct Answer: D

    When running terraform import on existing infrastructure, it is necessary to manually write a resource configuration block for the resource before executing the import command. The configuration block describes where Terraform should map the imported object. Terraform import does not generate configuration files for you; it only imports the state. Writing the configuration files beforehand ensures that the imported resources are correctly mapped and managed by Terraform.

Discussion
Uma10Option: D

The current implementation of Terraform import can only import resources into the state. It does not generate configuration. A future version of Terraform will also generate configuration. Because of this, prior to running terraform import it is necessary to write manually a resource configuration block for the resource, to which the imported object will be mapped. Source: https://www.terraform.io/cli/import

zyxphreezOption: C

i got confused..... check this url https://learn.hashicorp.com/tutorials/terraform/state-import the steps are 1. Identify the existing infrastructure you will import. 2. Import infrastructure into your Terraform state. 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. based on the learning path... i will choose C

SanderIsTheBestCloudShaper

this is true , its c

RVivek

2 second step mport infrastructure into your Terraform state requires confiuration to be written just an empty block with provider name and resource type and and resouce address for exapmple resource aws_instace "my-webserver" { } then you have to run terraform import ws_instace .my-webserver <instance-id> where instance-id of the Ec2 instace to be ipmorted. Then the sate is imported . from the state you have to copy other importanat values like VPC-id, subnet-id, ebs volume id ...

AB7088

the question said import on existing infrastructure, so it should be answer C. based on https://learn.hashicorp.com/tutorials/terraform/state-import

lezgino

Selected answer: D That is correct, Terraform configuration should be written before terraform import is executed. It's best to have the Terraform code reflect the current state of the infrastructure so that Terraform can manage it.

ChinensisOption: C

The answer is clearly written here: https://developer.hashicorp.com/terraform/tutorials/state/state-import Why debate? :)

lukacs16Option: D

"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 D. https://developer.hashicorp.com/terraform/cli/import/usage

FawadKOption: C

Answer is C. see https://developer.hashicorp.com/terraform/tutorials/state/state-import

kiran15789Option: C

the steps are 1. Identify the existing infrastructure you will import. 2. Import infrastructure into your Terraform state. 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.

TechHeroOption: A

You don't need to write resource configuration before importing Bringing existing infrastructure under Terraform's control involves five steps: 1. Identify the existing infrastructure you will import. 2. Import infrastructure into your Terraform state. 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. https://developer.hashicorp.com/terraform/tutorials/state/state-import?utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS The Correct Answer is: A

petersolimanOption: C

A. Infrastructure can be imported without corresponding Terraform code indeed but the question is saying should, so we should write the configurations sometime. B. Terraform will generate the corresponding configuration files for you that is also correct but with the plan command not import terraform plan -generate-config-out=generated_resources.tf that can be done after the importing, because you have the state file with the resources C. You should write Terraform configuration files after the next terraform import is executed that is the most correct for me. D. Terraform configuration should be written before terraform import is executed not sure why most people are choosing this one?!

8876ca1

Because of terraform import ADDR ID

[Removed]Option: C

Will pick D: Using configuration to import resources involves the following steps: 1. Identify the existing infrastructure you will import. 2. Define an import block for the resources. 3. Run terraform plan to review the import plan and optionally generate configuration for the resources. 4. Prune generated configuration to only the required arguments. 5. Apply the configuration to bring the resource into your Terraform state file. https://developer.hashicorp.com/terraform/tutorials/state/state-import

JhaggarOption: D

The correct statement is "Terraform configuration should be written before terraform import is executed". This is because Terraform import requires a corresponding resource block in the configuration file to identify and map the imported resource to the configuration. If the configuration file is not written before the import is executed, there will be no resource block available to map the imported resource to, which can result in an incomplete or incorrect state. After the import is executed, any necessary changes to the configuration file can be made to ensure that the configuration is up to date with the imported resources.

campsOption: D

D. Terraform configuration should be written before terraform import is executed When running terraform import on existing infrastructure, you should write the corresponding Terraform configuration files before executing the import command. The terraform import command requires that the resource configuration already exists in your Terraform code, as it maps the existing infrastructure to the defined resource in your configuration. The command then adds the imported resource information to your Terraform state file.

campsOption: D

D. Terraform configuration should be written before terraform import is executed. Terraform import is used to import an existing infrastructure into a Terraform configuration. Before running terraform import, the configuration files must be written to describe the desired state of the imported resources. Once the configuration is written and the import command is executed, Terraform maps the existing resources to the configuration and updates its state accordingly. Therefore, Terraform configuration files should be written before running terraform import on existing infrastructure.

noobsterOption: D

Before you run terraform import you must manually write a resource configuration block for the resource. https://developer.hashicorp.com/terraform/cli/import

ZeppoonstreamOption: D

D. Terraform configuration should be written before terraform import is executed When running the terraform import command on existing infrastructure, Terraform uses the configuration files to know how to interact with the resources. Without the configuration files, Terraform does not know how to interact with the resources and what to import. Therefore, Terraform configuration files should be written before terraform import is executed. A. Infrastructure can be imported without corresponding Terraform code is not true. B. Terraform will generate the corresponding configuration files for you is not true. C. You should write Terraform configuration files after the next terraform import is executed is not true. It's important to note that Terraform import is not a replacement for creating Terraform configuration files, but it helps to discover and populate the state with existing resources.

gekkehenkOption: D

According to Terraform, the configuration should be written before performing the import. "Before you run terraform import you must manually write a resource configuration block for the resource. The resource block describes where Terraform should map the imported object." https://developer.hashicorp.com/terraform/cli/import

AndreawOption: A

to import is not necessary update config. To apply yes, is tricky

robertninho

D. Terraform configuration should be written before terraform import is executed The terraform import command is used to import existing infrastructure into Terraform, so that it can be managed as part of your configuration. In order to use terraform import, you need to have a corresponding Terraform configuration file that defines the desired state of the infrastructure. Therefore, it is generally a good idea to write the Terraform configuration file before running terraform import. This will allow you to specify the desired state of the infrastructure, including any resources that you want to import and any additional resources or configurations that you want to add.

InformationOverloadOption: D

Terraform configuration files should be written before running the terraform import command on existing infrastructure. The configuration files define the infrastructure that Terraform will manage, and the terraform import command is used to import existing resources into the configuration so that Terraform can manage them.