Apply fails with `EntityAlreadyExists: Role with name app-role already exists.`
BeginnerTroubleshootingImport, Already Exists and State Surgery
Answer
Likely causes → The role was created manually, by another stack, or by a previous run whose state was lost. IAM names are unique per account.
Diagnose → aws iam get-role --role-name app-role --query 'Role.[Arn,CreateDate,Tags]' and check tags to find the owner.
Fix → If this stack should own it, import:
import {
to = aws_iam_role.app
id = "app-role"
}
If another stack owns it, rename yours or reference it with a data "aws_iam_role".
Prevent → Prefix names with stack/env (${var.env}-app-role) or use name_prefix so stacks can't collide.
More on Import, Already Exists and State Surgery
`terraform apply` on a new bucket fails with `BucketAlreadyExists`. You have never created that bucket.Beginner`Error: Resource already managed by Terraform` when running `terraform import aws_s3_bucket.logs acme-logs`.Beginner`Error: Cannot import non-existent remote object` for a resource you can see in the console.Intermediate`Error: Configuration for import target does not exist` when running `terraform plan` with an `import` block.Beginner`terraform plan -generate-config-out=generated.tf` fails with `Conflicting configuration arguments` in the generated file.IntermediateAfter importing an S3 bucket, the plan still shows `+ force_destroy = false` as an update.Beginner