Importing Existing Resources
Learn how to import already existing cloud infrastructure into your Terraform state, bringing pre-existing resources under IaC management.
Bring Existing Infra to IaC
Sometimes you have cloud resources that were created manually or by other tools. Terraform import allows you to bring these existing resources under Terraform's management.
This means Terraform will then track their state and future changes can be applied via your configuration files. It's a key step for adopting Infrastructure as Code (IaC) in a "brownfield" environment.
When You Need to Import
Importing is useful in several situations:
- Migrating existing infrastructure: Bringing resources created outside Terraform into your IaC workflow.
- Adopting Terraform gradually: Starting with existing resources rather than recreating everything.
- Recovering from state loss: Re-associating Terraform with resources if your state file is lost (though this is rare with remote state).
All lessons in this course
- Remote State Backends
- State Locking and Consistency
- Importing Existing Resources
- Refactoring State with moved and removed