-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to import in bulk #22219
Comments
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. |
Allow to import many different terraform resources in one command, by supplying a list of addr,id pairs. Basically, importing hundreds of resources takes a few hours before this cl, and a few mintues after it. To make implementation somewhat easier I have taken out a chunk of the mapping from args to targets into a smaller function, but the rest stays almost the same. Some error messages change a bit. Fixes hashicorp#22219
Is there anything I can do to help merge? This solution would be very helpful! @pkolyvas @teamterraform |
* does not store terraform state anywhere; just imports it on every run * would be nice if there was a bulk import feature! the internal API seems to support it. hashicorp/terraform#22219 * doesn't run apply yet - pushing this for a dry run first. part of #4 Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
This would indeed be a very useful feature :) For now, e.g. for Route53 entries, https://mrkaran.dev/posts/terraform-route53-import/ |
Importing multiple resources is a highly sought out feature. The implemenation should support parallelism to improve efficiency of import with multiple resources |
for anyone still interested, Google recently open sourced this https://github.com/GoogleCloudPlatform/terraformer |
Another possible solution for this could be to allow defining imports in the terraform code itself, similar to the new |
I've read a few of these bulk-import tickets now, I'm in a bit of a pickle defining our DR procedures. We've over 100 RDS tables , defined in terraform , full of data , backed up in AWS Backup Vault. If some maniac decides to delete all these tables we'd initiate the restore from AWS Backup, which would create 100 new tables, but then would we have to import each back into the tf state one by one ? The state is quite large and single import takes over a minute, So that'd be at least a couple of hours before we could actually terraform apply to create the rest of the missing infrastructure. I suppose we could manually hack the state file to switch these tables state to point to the new ones, but that smells bad to me. |
Bulk import is possible in Terraform v1.5+ with the use of |
@kmoe I gave that a try last week and it worked really well. Thanks for all of the work getting that over the line. |
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. |
Current Terraform Version
Use-cases
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).
Attempted Solutions
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.Proposal
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.The text was updated successfully, but these errors were encountered: