Terraform v0.7.0
aws_instance
terraform import -state bd44f.tfstate -input=true 'aws_instance.keepstore.1' i-51e996d1
2016/08/11 22:01:05 [INFO] Terraform version: 0.7.0 e822a79165dbc06bbf8271ee349fe256867d53dc
2016/08/11 22:01:05 [DEBUG] Detected home directory from env var: /root
2016/08/11 22:01:05 [DEBUG] Detected home directory from env var: /root
2016/08/11 22:01:05 [DEBUG] Attempting to open CLI config file: /root/.terraformrc
2016/08/11 22:01:05 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2016/08/11 22:01:05 [DEBUG] Detected home directory from env var: /root
2016/08/11 22:01:05 [TRACE] Graph after step *terraform.ConfigTransformer:
2016/08/11 22:01:05 [DEBUG] plugin: waiting for all plugin processes to complete...
Error importing: failed to parse resource address 'aws_instance.keepstore.1': Unexpected value for InstanceType field: "1"
when I execute terraform plan
it shows me aws_instance.keepstore.1 to be created, but I have an instance with that number
If I use terraform import aws_instance.keepstore[1] i-51e996d1 instead, it doesn't complain. But actually assigns the imported state to aws_instance.keepstore resource, which makes me think this is a bug.
I confirm the bug . I used import, inspected the state file, changed "aws_instance.keepstore" to "aws_instance.keepstore.X" and works. So we just need the validation not to be there.
Same issue as #7691
Fixed #7691 which is the same here.
@mitchellh @nicocesar Fix in #7691 does not seem to work if using modules. eg:
terraform import module.some_module.aws_instance.swarm_managers[0] i-xxxxxxx
I tried something like
terraform import module.some_module.aws_instance."swarm_managers[0] i-xxxxxxx"
terraform import module.some_module.aws_instance."swarm_managers[0]" i-xxxxxxx
and it worked fine.
I'm on terraform v0.11.13
Hi @xiaodong-xie , I believe that you wanted to say:
terraform import module.some_module.aws_instance."swarm_managers[0]" i-xxxxxxx
I tested the version you sent and didn't worked!
Hehe, yeah, sorry for the typo. @rzamana.
Did you use something like terraform state rm module.some_module.aws_instance.swarm_managers before terraform import?
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
@mitchellh @nicocesar Fix in #7691 does not seem to work if using modules. eg:
terraform import module.some_module.aws_instance.swarm_managers[0] i-xxxxxxx