Question 1
IntermediateManage Resource Lifecycle · Manage resource state, including importing resources and reconciling resource drift
You are the Lead Terraform Architect for a financial services firm. You are refactoring a large monolithic configuration into smaller, reusable modules to improve maintainability. One specific resource, an aws_s3_bucket named logs, needs to be moved from the root configuration into a new child module named audit_logs. You must ensure that the existing bucket is NOT destroyed and recreated during this refactoring process, as it contains petabytes of compliance data. Which configuration block should you add to your root module to facilitate this state migration?
Answer and explanation
Correct answer: D
The moved block allows you to refactor infrastructure code without destroying and recreating resources. By specifying the from address (the old resource location) and the to address (the new location inside the module), Terraform interprets the change as a rename in the state file rather than a create/destroy action.
