nerdexam
HashiCorp

TA-002-P · Question #403

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

The correct answer is D. Terraform configuration should be written before terraform import is executed. 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…

Use the Terraform CLI (terraform plan, apply, destroy, fmt, init, validate, workspace, import, taint, providers, output)

Question

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

Options

  • AInfrastructure can be imported without corresponding Terraform code
  • BTerraform will generate the corresponding configuration files for you
  • CYou should write Terraform configuration files after the next terraform import is executed
  • DTerraform configuration should be written before terraform import is executed

How the community answered

(50 responses)
  • A
    2% (1)
  • B
    8% (4)
  • C
    4% (2)
  • D
    86% (43)

Explanation

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.

Topics

#terraform import#configuration#CLI#existing infrastructure

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice