An import block says which existing object should become which resource address. You also need a matching resource block.
import {
to = aws_s3_bucket.logs
id = "my-company-logs"
}
resource "aws_s3_bucket" "logs" {
bucket = "my-company-logs"
}
Run tofu plan. The plan shows the import before anything is written to state. If it also shows changes to the resource, your resource block does not match reality yet — fix the code, not the resource.
OpenTofu can generate resource blocks for resources not yet declared, with -generate-config-out. The docs mark this as experimental, and it does not work together with for_each on import blocks. Treat the output as a draft to clean up.
A for_each argument on an import block imports several objects as instances of one resource.
Apply once the plan shows only the import. An import block is active only while the object is not yet tracked at its to address, so leaving it in place is harmless.
plan must show no changes. Anything else means the code is wrong.Examples use OpenTofu (tofu); in Terraform the commands start with terraform. Check the documentation for your version before relying on a feature.
Tell us what you are trying to fix. No preparation needed.