terraform config_error ai_generated true

错误:导入 ID 格式无效:应为 <资源类型>.<名称> <ID>

Error: Invalid import ID format: expected <resource_type>.<name> <id>

ID: terraform/invalid-import-id-format

其他格式: JSON · Markdown 中文 · English
95%修复率
85%置信度
1证据数
2024-01-15首次发现

版本兼容性

版本状态引入弃用备注
Terraform v1.8.0 active
Terraform v1.9.0 active
Terraform v1.10.0 active

根因分析

导入命令需要特定的两部分参数格式(资源地址和 ID),但用户提供了单个字符串或格式错误的输入。

English

The import command requires a specific two-part argument format (resource address and ID), but the user provided a single string or malformed input.

generic

官方文档

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

解决方案

  1. Use the correct two-argument format with a space: `terraform import aws_instance.my_instance i-12345`
  2. If using shell variables, ensure they expand to separate arguments: `terraform import aws_instance.my_instance "$INSTANCE_ID"`

无效尝试

常见但无效的做法:

  1. 80% 失败

    Terraform expects a space separator between the resource address and the ID, not a colon or other delimiter.

  2. 90% 失败

    The import command treats the quoted string as a single argument, so it doesn't parse the resource address and ID separately.