Which command would bring existing infrastructure under Terraform management?

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

Which command would bring existing infrastructure under Terraform management?

Explanation:
Bringing existing infrastructure under Terraform management requires telling Terraform about resources that already exist so it can track them in its state. The import command does exactly this: it reads a real resource (for example, an AWS EC2 instance or a GCP VM) and records it in Terraform’s state, linking it to a resource name you’ll have in your configuration. Importing doesn’t create anything new; it simply adopts the existing resource so Terraform can manage future changes. After importing, you should have a matching resource block in your configuration that describes the desired settings, and then plan and apply can reconcile any drift. Other commands don’t bring resources into management. Initializing prepares the working directory and installs providers. Plan shows what would change based on the current configuration. Apply executes those changes to reach the desired state. Import is the step that transitions existing infrastructure into Terraform’s manage-and-track lifecycle.

Bringing existing infrastructure under Terraform management requires telling Terraform about resources that already exist so it can track them in its state. The import command does exactly this: it reads a real resource (for example, an AWS EC2 instance or a GCP VM) and records it in Terraform’s state, linking it to a resource name you’ll have in your configuration. Importing doesn’t create anything new; it simply adopts the existing resource so Terraform can manage future changes. After importing, you should have a matching resource block in your configuration that describes the desired settings, and then plan and apply can reconcile any drift.

Other commands don’t bring resources into management. Initializing prepares the working directory and installs providers. Plan shows what would change based on the current configuration. Apply executes those changes to reach the desired state. Import is the step that transitions existing infrastructure into Terraform’s manage-and-track lifecycle.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy