$ terraform -v
Terraform v0.12.6-dev
While starting to manage infrastructure with terraform, I have hundreds of resources that I need to import. I want to be able to import all resources from a file that I have generated (in my case using the AWS API).
I've gotten something that works by generating a script that has hundreds of calls to the terraform import command. However, it is very slow to run, because every single call has to acquire the lock, fetch the state (from S3), perform the import, store the state, and release the lock. It would be much more efficient if acquiring the lock, fetching the state, storing the state, and releasing the lock was done just once for all resources.
Add on option to the terraform import command which accepts a file. The file should have a resource address and resource id seperated by a space on each line, and it should then acquire the lock and fetch the state, then import all resources in that file, then store the state and release the lock.
Want to chime in that we (at NS1) are quite interested in the outcome of this issue/PR. We have some bulk import use cases. It can take quite some time to get 50k+ resources imported and seems like this could help a lot!
I'd like to import all resources for certain providers. For example, I'm using mysql provider to create users and grants. I am creating hundreds of mysql resources. Most of those resources are already created using some other process. I'd be nice to have an ability to import all existing mysql users and grants to a terraform state file. Without this, when I apply terraform, it complains about the existing resources. And, there is no way to import all existing mysql resources in one shot.
Also have a use case that this would help with tremendously. When trying to help customers manage sets of existing infrastructure using terraform, the ability to only import one resource at a time feels crippling.
Is there anything I can do to help merge? This solution would be very helpful! @pkolyvas @teamterraform
Most helpful comment
Also have a use case that this would help with tremendously. When trying to help customers manage sets of existing infrastructure using terraform, the ability to only import one resource at a time feels crippling.