liveBook · Manning

Resource import

As explained in Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform

A tool feature that adopts existing infrastructure resources into the tool's managed configuration or state.

Resource import adopts an existing infrastructure resource into a provisioning tool’s managed state, allowing infrastructure as code to match live resources without recreating them. After importing, rerun the configuration and inspect the plan to detect and reconcile drift. section 2.2.2 section 13.5

Apply resource import as a controlled migration workflow:

  • Inspect the existing resource and reconstruct configuration that matches its actual name, identifiers, and attributes. section 2.2.2
  • Copy the configuration into an isolated directory, repository, or state when separating resources from a monolithic configuration. section 10.2.1
  • Import the live resource identifiers into the new state, then run a dry run or plan before changing the active infrastructure. section 10.2.1 section 13.3.1
  • Confirm that the plan reports no unintended changes; remove the resource from the old configuration and state only after verification. section 10.2.1
  • Migrate low-level or independent resources before dependent resources, updating dependencies through dependency injection when necessary. section 10.2.3 section 13.5

Separating IAM resources from a monolith

Copy the IAM configuration into a separate directory, initialize its state, and import the existing service accounts and roles. Run Terraform and verify that the plan reports no changes. Then remove those resources from the monolithic configuration and state, preserving the live infrastructure while completing the refactor. section 10.2.1

How Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform covers it

How deep it goes
Explains configuration matching, state import, dry-run verification, dependency ordering, and removal from old state; it defers provider-specific command detail.
Examples
Demonstrates importing development networks, GCP IAM resources, and resources migrated into a new infrastructure DSL.
What it assumes
Assumes familiarity with infrastructure as code, provisioning-tool state, configuration, dependencies, and dry-run or plan output.
What you can do after
Operate/configure Terraform-managed resources by importing identifiers, checking plans for drift, and safely removing obsolete state ownership.
How it connects
Connects resource import to infrastructure as code, tool state, drift, idempotency, dependency injection, and blue-green deployment.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform. The section links point to the parts of the book it draws on.