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
Import resources into Terraform #581
Comments
I think this doesn't need language support, instead you just need the ability to import the existing subnet into the tfstate file (and give it the name "b" in the process). Then Terraform would reuse the existing one instead of creating a new one to fill the "b" slot. I.e. that conditional if defined(...) essentially already exists in the core terraform planning logic to check if a resource already exists in the tfstate. |
Would the recommended way forward for this be then to create a script that traverses an AWS network, getting all Route53 records, VPC information, instance data, etc, and generating the appropriate tfstate JSON + example .tf files? |
Correct. Ideally the tool would be able to scan resources on various provides and with operator assistance map it to config logical names. |
+1 to this one for us. Keeps us from being able to launch new clusters of our service into an existing VPC. Any update on this one since Dec? |
No specific update on the feature itself, it's still on the roadmap. But I wanted to jump in here to link an excellent article by @phrawzty on a strategy for dealing with existing resources with current versions of terraform: https://www.dark.ca/2015/01/27/handling-extant-resources-in-terraform/ |
+1, would love to see this (soon). |
An alternative approach could be something inspired by |
I like @AlexanderEkdahl suggestion. This would be awesome and we could keep people out of the state file - @mitchellh @catsby, thoughts? I'd be willing to do a POC for something like this. |
Thats a pretty neat idea. Could help basic stuff... What do you think @phinze? |
Agreed - I think that would be a really valuable baby step to take. |
Cool. |
I put together a very simple POC for discussion - #2022 |
Separate from @johnrengelman's POC (where I commented, too), I feel like a missing part of this conversation is actually generating the Terraform config. I'd expect it to still be a relatively manual, iterative process, but I'd want |
+1 to @blalor's comment, though I would advocate for taking this in separate.. the first being coverage for inport to begin with.. generating config has more nuances and work in general. |
Others may find this tool helpful. I tested the EC2, ELB, security group, and VPC capabilities and it was able to extract existing AWS infrastructure into resources. https://github.com/dtan4/terraforming |
|
Would love to see this as well, this functionality would allow us to start using terraform at my company to manage existing infrastructure. +1 |
|
1 similar comment
|
I'll join the party. This would be a huge feature. |
I am trying to create new subnets in existing vpc. variable "aws_vpc" { Getting below error:- |
@JigarS91 https://www.terraform.io/community.html is the place to ask these questions :) |
|
+1 it will be good to have feature in terraform. |
terraforming is working OK for me too. My process is essentially to export all resources into tfstate form, then rename the ones I'm importing, and delete the others. Would be great to have this functionality built into terraform. |
This is a bit of a show stopper for my application - I don't want to edit the tfstate if I can avoid it... any update on whether this will be moving forward in one form or another? |
|
1 similar comment
|
|
+1, this makes it much easier to recover from partial applies |
|
3 similar comments
|
|
+1 |
Folks, github has had reactions for a while. Please stop the +1 and thumbs up. |
seconded on a request for an update, clearly this is something that the community wants. If the response is that hey this will be included in version 0.6.20 then so be it. |
Looking at the work on the master branch, parts of this (or maybe all) will be in 0.7. |
The basics of this are in master and will be part of 0.7. See the website subfolder for docs until it is released. More fancy features such as config generation will come, but 0.7 will be able to import resources into Terraform. This is just the beginning, but we're finally getting there! |
Anyone interesting the converter, you need to follow up this ticket: |
You can try new solution https://github.com/GoogleCloudPlatform/terraformer |
I'm going to lock this issue because it has been closed for 30 days 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. |
Use case , manage infrastructure environments both existing and created from scratch, by same terraform configs. For example in development environments we want to create everything from scratch and destroy everything then we finish working with it. In production we want to be able to add new resources to it with terraform but not conflict with resources that already exist but not managed by terrafrom yet.
For ex:
}
if terraform has not yet created this resource it will check if subnet_b_id is defined and if resource with such id exists in provider api it will import this resource into terraform based on data in api instead of creating it.
The text was updated successfully, but these errors were encountered: