Import

Hands-on: Try the Import Terraform Configuration tutorial.

Terraform can import existing infrastructure resources. This functionality lets you bring existing resources under Terraform management.

State Only

The 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.

HCP Terraform

When you use Terraform on the command line with HCP Terraform, many commands like apply run inside your HCP Terraform environment. However, the import command runs locally, so it does not have access to information from HCP Terraform. To successfully perform an import, you may need to set local variables equivalent to any remote workspace variables in HCP Terraform.