Importing Existing Resources
An S3 bucket acme-logs-prod was created by hand in the console. You want Terraform to manage it without recreating it, and you would like Terraform to draft the resource code for you. What do you do?
acme-logs-prod
Choose one answer
Write a matching resource block and run apply; Terraform adopts the bucket by name.
resource
apply
Run terraform apply -refresh-only with the bucket name so it's added to state.
terraform apply -refresh-only
Add an import block, then plan -generate-config-out=generated.tf.
import
plan -generate-config-out=generated.tf
Add a data "aws_s3_bucket" block and run plan -generate-config-out=generated.tf.
data "aws_s3_bucket"