terraform resource_error ai_generated true

错误:无法导入不存在的远程对象:导入 ID 格式无效或对象不存在

Error: Cannot import non-existent remote object: the import ID format is invalid or the object does not exist

ID: terraform/import-id-format-mismatch

其他格式: JSON · Markdown 中文 · English
90%修复率
86%置信度
1证据数
2023-11-12首次发现

版本兼容性

版本状态引入弃用备注
Terraform >=1.0 active
AWS Provider 5.x active
AzureRM Provider 3.x active

根因分析

提供给 `terraform import` 的导入 ID 与资源类型的预期格式不匹配,或引用的云资源不存在。

English

The import ID provided to `terraform import` does not match the expected format for the resource type, or the referenced cloud resource does not exist.

generic

官方文档

https://developer.hashicorp.com/terraform/cli/commands/import

解决方案

  1. 查阅提供程序文档以获取正确的导入 ID 格式。例如,`terraform import aws_instance.my_instance i-1234567890abcdef0`。
  2. 使用 `terraform plan -generate-config-out=generated.tf` 从现有资源自动生成配置,避免手动导入。

无效尝试

常见但无效的做法:

  1. 80% 失败

    Each resource type has a specific import ID syntax; guessing often results in invalid format.

  2. 65% 失败

    Some resources require the resource ID (e.g., `i-abc123`) not the ARN; using ARN causes a mismatch.