How is Terraform import executed?

Prepare for the HashiCorp Terraform Associate Exam with quizzes, flashcards, and multiple-choice questions. Each question includes hints and explanations. Boost your confidence and ace your exam!

Multiple Choice

How is Terraform import executed?

Explanation:
Importing an existing resource into Terraform state is an explicit action you perform with a dedicated command, not something Terraform does as part of its normal workflow. The import operation links a real-world resource to a corresponding resource in your configuration by writing its details into the Terraform state. You must specify the resource type and name in your config and provide the resource’s real-world identifier, then run the import command, for example: terraform import aws_instance.web i-1234567890abcdef0. This makes Terraform aware of the resource so subsequent plan and apply steps can manage it. The other options don’t perform this linking step. Initialization prepares providers and modules, planning computes changes to reach the desired state, and refreshing updates the state to reflect the current reality. None of those actions bring an existing resource into the state by explicit reference.

Importing an existing resource into Terraform state is an explicit action you perform with a dedicated command, not something Terraform does as part of its normal workflow. The import operation links a real-world resource to a corresponding resource in your configuration by writing its details into the Terraform state. You must specify the resource type and name in your config and provide the resource’s real-world identifier, then run the import command, for example: terraform import aws_instance.web i-1234567890abcdef0. This makes Terraform aware of the resource so subsequent plan and apply steps can manage it.

The other options don’t perform this linking step. Initialization prepares providers and modules, planning computes changes to reach the desired state, and refreshing updates the state to reflect the current reality. None of those actions bring an existing resource into the state by explicit reference.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy