terraform config_error ai_generated true

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

ID: terraform/invalid-import-id-format

Also available as: JSON · Markdown · 中文
95%Fix Rate
85%Confidence
1Evidence
2024-01-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Terraform v1.8.0 active
Terraform v1.9.0 active
Terraform v1.10.0 active

Root Cause

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

中文

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

Official Documentation

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

Workarounds

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

中文步骤

  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"`

Dead Ends

Common approaches that don't work:

  1. 80% fail

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

  2. 90% fail

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