`terraform import 'aws_instance.web["api"]' i-0abc` fails in bash with `Error: Index value required` or the address looks mangled.
BeginnerTroubleshootingImport, Already Exists and State Surgery
Answer
Likely causes → Shell quoting. Without single quotes, bash strips the inner double quotes, so Terraform receives aws_instance.web[api].
Diagnose → echo aws_instance.web["api"] prints the mangled address.
Fix →
terraform import 'aws_instance.web["api"]' i-0abc123 # bash/zsh
terraform import 'aws_instance.web[\"api\"]' i-0abc123 # PowerShell
Or avoid quoting entirely with an import block in code.
Prevent → Use import blocks and moved blocks rather than CLI addresses.
More on Import, Already Exists and State Surgery
Apply fails with `EntityAlreadyExists: Role with name app-role already exists.`Beginner`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.Intermediate