Interview Prep/Terraform/Import, Already Exists and State Surgery

A `moved` block inside your module referencing a resource in a registry module fails with `Cross-package move statement`.

AdvancedTroubleshootingImport, Already Exists and State Surgery
Answer

Likely causes → moved can only refer to objects within your module package; you can't move into or out of a separately installed module's internals from inside it.

Diagnose → The error names the external package source.

Fix → Put the moved block in the calling module, using full module paths:

moved {
  from = aws_vpc.main
  to   = module.vpc.aws_vpc.this[0]
}

Prevent → Do refactors that cross module boundaries in the root module, and look up the registry module's real resource names and instance keys first.

All Terraform questions Roadmap: Terraform in production

More on Import, Already Exists and State Surgery