Which action brings existing external resources under Terraform management by creating an entry in the state file?

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 action brings existing external resources under Terraform management by creating an entry in the state file?

Explanation:
Importing an existing external resource is the way to bring it under Terraform management. Terraform’s state file tracks what it manages, and an entry in that state links a resource defined in your configuration to a real resource that already exists. Running the import creates that state entry without changing the actual resource. You need a matching resource block in your configuration and you provide the identifier of the existing resource (for example, an AWS instance ID). Once imported, Terraform can plan and apply changes to align the real resource with your configuration. Destroy would remove the resource rather than add it to state. Refresh updates the state to reflect the current real-world attributes but doesn’t create a new entry for something Terraform didn’t know about. Initialize the backend only sets up where the state is stored and does not touch resources.

Importing an existing external resource is the way to bring it under Terraform management. Terraform’s state file tracks what it manages, and an entry in that state links a resource defined in your configuration to a real resource that already exists. Running the import creates that state entry without changing the actual resource. You need a matching resource block in your configuration and you provide the identifier of the existing resource (for example, an AWS instance ID). Once imported, Terraform can plan and apply changes to align the real resource with your configuration.

Destroy would remove the resource rather than add it to state. Refresh updates the state to reflect the current real-world attributes but doesn’t create a new entry for something Terraform didn’t know about. Initialize the backend only sets up where the state is stored and does not touch resources.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy