terraform import

Bringing an existing, hand-made object under Terraform management by recording it in state against a resource address.

In more detail

Since Terraform 1.5 you write an import block with the object's identifier and the target address, and the next plan shows the import before it happens. Import only records ownership: it creates nothing, and you must still write matching configuration, or generate a draft with plan -generate-config-out. The older terraform import command writes to state immediately without a plan.

Example

import {
  to = aws_vpc.main
  id = "vpc-0abc123"
}

Related terms

Taught in

References

Certification courses