terraform
config_error
ai_generated
true
错误:命令行参数过多:导入命令期望 2 个参数,实际收到 3 个
Error: Too many command line arguments: expected 2 for import, got 3
ID: terraform/too-many-arguments-to-import
90%修复率
85%置信度
1证据数
2024-02-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Terraform v1.7.0 | active | — | — | — |
| Terraform v1.8.0 | active | — | — | — |
| Terraform v1.9.0 | active | — | — | — |
根因分析
terraform import 命令被调用的位置参数超过了所需的两个(资源地址和 ID),通常是由于多余参数或字符串引用错误。
English
The terraform import command was invoked with more than the required two positional arguments (resource address and ID), often due to extra arguments or misquoted strings.
官方文档
https://developer.hashicorp.com/terraform/cli/commands/import解决方案
-
Place all flags before the arguments: `terraform import -input=false aws_instance.my_instance i-12345`
-
If you need to specify a provider alias, use it in the resource address: `terraform import 'aws_instance.my_instance[provider=aws.us_east_1]' i-12345`
无效尝试
常见但无效的做法:
-
70% 失败
Flags must be placed before the positional arguments, not after. Terraform interprets -input=false as a third positional argument.
-
60% 失败
Provider aliases are specified via the resource address itself (e.g., aws_instance.my_instance[provider=aws.us_east_1]), not as a separate argument.