Context
Importing tells Terraform that an existing remote object belongs at a particular resource address in state. It does not infer the object's business purpose or guarantee that the proposed configuration preserves its behavior. A first import can also contain updates or replacement. Review the whole plan rather than accepting the word import as evidence of a harmless operation.
Prerequisites are the correct backend and workspace, the object's owner, a provider-supported import identifier, an approved state-protection procedure, and pinned tool/provider versions. Use an isolated review branch. Initial validation and planning should not change infrastructure, though provider reads still require the expected credentials.
1. Establish identity and ownership
Confirm the object is not already managed by another Terraform address or workspace. Terraform expects one remote object to map to one resource instance. Inventory its dependencies and the API account or endpoint the provider is targeting.
terraform workspace show
terraform state list
terraform providers
Do not switch workspaces or change provider targets merely to make an identifier resolve. Resolve the ownership question first. Provider import identifiers vary by resource, so obtain the documented format from that resource's provider documentation rather than guessing from a display name.
2. Declare a destination and import block
An explicitly illustrative Docker-provider import names an already existing test container:
import {
to = docker_container.catalog
id = "FULL_EXISTING_CONTAINER_ID"
}
The identifier is a placeholder. Add or generate the matching resource configuration with the correct provider requirements. The example is not authorization to import a production container, and it omits environment-specific resource arguments intentionally.
When you do not yet have the resource block, supported configuration-driven import can generate a starting point:
terraform plan -generate-config-out=import-review.tf
Use a new output filename. Generated configuration needs review; it can include defaults, conflicting arguments, or values that should become references. It is not an architectural model of the resource's dependencies.
3. Inspect every planned action
terraform validate
terraform plan
Check the import address and identity, then inspect additions, updates, replacements, and deletions. Compare behaviorally significant settings with the live object's approved configuration. A provider may also persist management settings that the remote API does not report, so a displayed difference needs interpretation rather than automatic acceptance.
For the first ownership handoff, prefer a plan whose intended effect is importing the object without changing its service behavior. Separate unrelated standardization or redesign work into a later reviewed change.
Diagnose unexpected import results
| Plan evidence | Possible explanation | Next review |
|---|---|---|
| Object resolves in the wrong account or endpoint | Provider target mismatch | Provider configuration and identity |
| Replacement appears beside import | Configuration changes immutable behavior | Resource schema and live settings |
| Generated arguments conflict | Incomplete generated template | Required versus mutually exclusive fields |
| Object already exists in another state | Duplicate management risk | Workspace ownership and state inventory |
Do not use state-removal or address-manipulation commands to bypass an unclear plan. The right correction may be a different import destination, provider configuration, or resource declaration.
Verify the approved handoff and maintain records
Only apply an explicitly reviewed plan through the established change workflow. After import, run a fresh plan and confirm the expected stable result. Verify the application or resource remains usable through a harmless acceptance check.
Keep the import identity, destination address, provider target, owner, and acceptance evidence in the infrastructure SOP. Retain import blocks when they provide useful history. Future reviewers should be able to distinguish the original ownership handoff from subsequent changes to the resource.
Explore Clouvenix terraform automation for implementation and operational handover.
Technical reference
Single-resource imports, configuration generation and Docker import tutorial.