Courseiva
Use Terraform outside the core workfloweasyMultiple SelectObjective-mapped

TF-004 Use Terraform outside the core workflow Practice Question

Which TWO of the following are valid methods for importing existing infrastructure into Terraform management? (Choose two.)

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Use a third-party tool like Terraformer to generate configuration

The typical method is to write configuration and run terraform import. Third-party tools can generate configuration from existing resources. terraform import requires configuration beforehand. terraform state push is not for importing; it pushes a state file. terraform apply would try to create new resources.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Use terraform apply directly on existing resources

    Why it's wrong here

    Using `terraform apply` directly on existing resources is incorrect because this command is designed to create, update, or destroy infrastructure based on the desired state defined in HCL configuration and the current state in the state file. If a resource exists in the cloud but is not in the state file, `terraform apply` would attempt to create a *new* resource, leading to errors or duplicates, rather than importing the existing one into management.

  • Use a third-party tool like Terraformer to generate configuration

    Why this is correct

    Using a third-party tool like Terraformer is a valid method because these tools automate the complex process of reverse-engineering existing cloud infrastructure into Terraform HCL configuration files. By generating the necessary `resource` blocks, they provide the essential configuration required for Terraform to manage existing resources. This significantly streamlines the adoption of Terraform for existing environments, often also facilitating the population of the Terraform state.

  • Use terraform state push to manually add state entries

    Why it's wrong here

    Using `terraform state push` to manually add state entries is an invalid method for importing resources. This command is specifically used to upload a local Terraform state file to a remote backend, typically after manual modifications or for recovery purposes. It requires a complete and valid state file as input and does not possess any functionality to discover existing cloud resources or generate the necessary state entries for them.

  • Write configuration for the resource and use terraform import

    Why this is correct

    Writing configuration for the resource and then using `terraform import` is the standard, native Terraform method for bringing existing infrastructure under management. This involves manually creating a `resource` block in HCL that accurately describes the existing cloud resource. Subsequently, the `terraform import <resource_address> <resource_id>` command is executed, linking the existing cloud resource to the defined configuration block within the Terraform state file.

  • Use terraform import without any prior configuration

    Why it's wrong here

    Attempting to use `terraform import` without any prior configuration is incorrect because the command explicitly requires a corresponding `resource` block to be present in the Terraform configuration files. Without a predefined configuration block, Terraform would not know where to map the imported resource within its desired state, resulting in an error. The command's purpose is to populate the state for an *already defined* resource, not to discover and define resources on its own.

About these practice questions

This TF-004 question is part of Courseiva's 428-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This TF-004 practice question is part of Courseiva's free HashiCorp certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the TF-004 exam.