You need to move a resource from one module call to another within the same state.
IntermediateScenarioImport Refactoring Drift and Lifecycle
Answer
Situation read → Address change across module boundaries.
What I'd do → Use a moved block with full addresses.
moved {
from = module.old_app.aws_lb.this
to = module.new_app.aws_lb.this
}
For moves between different states, moved doesn't work; use import in the target and removed { destroy = false } in the source.
Why → moved only rewrites addresses in the same state. Cross-state moves require forgetting in one and importing in the other.
Interview tip → Apply the import side first, then the removal, to avoid an unmanaged gap.
More on Import Refactoring Drift and Lifecycle
An S3 bucket was created by hand in the console and now must be managed by Terraform. How do you bring it in?BeginnerYou must adopt 200 existing resources and don't want to write all the HCL by hand.IntermediateHow do you find out that someone changed infrastructure outside Terraform?BeginnerSomeone opened port 22 on a security group in the console. Terraform wants to remove it. What's your process?IntermediateAn Auto Scaling group's desired capacity is changed by autoscaling, and Terraform keeps resetting it.IntermediateHow do you protect a production database from an accidental `terraform destroy`?Beginner