An engineer imports an existing S3 bucket into Terraform, then runs terraform plan without changing the configuration. Terraform reports one attribute that differs from the configuration. Why can Terraform detect this difference at all?
terraform import aws_s3_bucket.assets my-existing-bucket
terraform plan- ABecause Terraform queries the provider's live API on every plan and never relies on stored data.
- BBecause import also generates the matching resource block, so plan compares two generated files.
- CBecause the import wrote a resource-to-real-world mapping into state, which plan then compares against the configuration. Correct
- DBecause the S3 bucket stores its own Terraform metadata that plan reads back on each run.
Why A is wrong: Terraform does refresh against the provider, but the comparison that surfaces a diff is made between configuration and the mapping recorded in state, not the live API alone.
Why B is wrong: Classic import does not author the configuration block for you; the mapping lands in state and the practitioner still writes the HCL, so this misstates how import works.
Why C is correct: Import records the real bucket under the resource address in state, giving Terraform a stored mapping it can diff against the configuration to reveal the mismatched attribute.
Why D is wrong: Managed resources do not carry Terraform metadata in the cloud; the mapping and metadata that plan needs live in the state file, not on the bucket itself.