terraform
config_error
ai_generated
true
Error: Too many command line arguments: expected 2 for import, got 3
ID: terraform/too-many-arguments-to-import
90%Fix Rate
85%Confidence
1Evidence
2024-02-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Terraform v1.7.0 | active | — | — | — |
| Terraform v1.8.0 | active | — | — | — |
| Terraform v1.9.0 | active | — | — | — |
Root Cause
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.
generic中文
terraform import 命令被调用的位置参数超过了所需的两个(资源地址和 ID),通常是由于多余参数或字符串引用错误。
Official Documentation
https://developer.hashicorp.com/terraform/cli/commands/importWorkarounds
-
95% success Place all flags before the arguments: `terraform import -input=false aws_instance.my_instance i-12345`
Place all flags before the arguments: `terraform import -input=false aws_instance.my_instance i-12345`
-
90% success 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`
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`
中文步骤
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`
Dead Ends
Common approaches that don't work:
-
70% fail
Flags must be placed before the positional arguments, not after. Terraform interprets -input=false as a third positional argument.
-
60% fail
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.