Terraform import: existing resources and state
Object identity
Import connects an existing provider object with a Terraform resource address. A matching name is not enough. Before importing, identify the provider object, the target address and whether another state already manages it.
resource "lab_server" "dispatch" {
name = "cedar-dispatch"
size = 4
}
import {
to = lab_server.dispatch
id = "existing-dispatch-42"
}
This is an original example for the course’s fictional provider. It assumes that the supplied object already exists. Real providers define their own import identifiers and supported import behavior.
The next plan
After importing, compare configuration with the object. If configuration asks for size 2 while the provider holds size 4, import does not choose which size the owner intended. Read the next plan and settle that difference before applying it.
The official import guide explains configuration-driven import and its requirements. Continue with state inspection and moved blocks. Removing a binding from state leaves the provider object in place; it is a separate action from destroying that object.