terraform resource_error ai_generated true

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

Also available as: JSON · Markdown · 中文
90%Fix Rate
86%Confidence
1Evidence
2023-11-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Terraform >=1.0 active
AWS Provider 5.x active
AzureRM Provider 3.x active

Root Cause

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

中文

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

Official Documentation

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

Workarounds

  1. 95% success Check the provider documentation for the correct import ID format. For example, `terraform import aws_instance.my_instance i-1234567890abcdef0`.
    Check the provider documentation for the correct import ID format. For example, `terraform import aws_instance.my_instance i-1234567890abcdef0`.
  2. 80% success Use `terraform plan -generate-config-out=generated.tf` to auto-generate configuration from an existing resource, avoiding manual import.
    Use `terraform plan -generate-config-out=generated.tf` to auto-generate configuration from an existing resource, avoiding manual import.

中文步骤

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

Dead Ends

Common approaches that don't work:

  1. 80% fail

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

  2. 65% fail

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