Hands-on: Try the Import Terraform Configuration tutorial.
Terraform can import existing infrastructure resources. This functionality lets you bring existing resources under Terraform management.
Note: Terraform v1.5.0 and later supports
import blocks. Unlike the
terraform import command, you can use
import blocks to import more than one resource at a time, and you can review imports as part of your normal plan and apply workflow. Learn more about
Warning: Terraform expects that each remote object is bound to a single resource address. You should import each remote object to one Terraform resource address. If you import the same object multiple times, Terraform may exhibit unwanted behavior. See State for more details.
terraform import CLI command can only import resources into the state. Importing via the CLI does not generate configuration. If you want to generate the accompanying configuration for imported resources, use the
import block instead.
Before you run
terraform import you must manually write a
resource configuration block for the resource. The resource block describes where Terraform should map the imported object.
When you use Terraform on the command line with Terraform Cloud, many commands like
apply run inside your Terraform Cloud environment. However, the
import command runs locally, so it does not have access to information from Terraform Cloud. To successfully perform an import, you may need to set local variables equivalent to any remote workspace variables in Terraform Cloud.