-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add import support #6
Comments
not sure it is so easy. I can't think of a way to find the configuration of a machine, especially if it is split into multiple modules. Maybe the cases of a single configuration.nix in the default location could work. |
Oh, would you need to do that? I thought it would be enough to just store the store path that the current-system symlink points to |
I don't think I fully understand the use case. If you write a new resource pointing to an existing nixos install, it will read the system and update only if it differs already - It won't really do anything destructive. |
It's just about bringing an existing network into Terraform. For example, I have a machine |
Perhaps another way to think about it is: I should be able to write a Terraform configuration, deploying it, delete my state, and then using only |
Hmm, terraform plan may say it is creating a new resource - but then when the creation actually runs, I don't think anything would happen. I will leave this issue open though, maybe it isn't too hard to support. |
I don't know if you're interested in this anymore. Usually, resources are based on some canonical ID, like an ARN in AWS; and that state can be used to find the resource in the real world and load its state the next time Read is invoked. Here however, the resources are given random IDs, as finding the nixos server is simply a matter of interrogating the host via ssh. So I think for a Importer: &schema.ResourceImporter{
State: func(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
d.SetId(randomID())
return []*schema.ResourceData{d}, nil
},
}, Then when |
I imagine it would be
terraform import nix_nixos.foo <readlink /run/current-system on remote host>
.The text was updated successfully, but these errors were encountered: