vultr / terraform-provider-vultr

Terraform Vultr provider
https://www.terraform.io/docs/providers/vultr/
Mozilla Public License 2.0
191 stars 65 forks source link

[Feature] - Support import for vultr_kubernetes and vultr_kubernetes_node_pools #310

Open jtackaberry opened 1 year ago

jtackaberry commented 1 year ago

Currently existing VKE clusters and node pools can't be imported into state. This feature request is just to provide some means of importing these existing resources.

optik-aper commented 1 year ago

@jtackaberry Thanks for the issue. I'll spend some time testing this out and see what we can do.

Stealthmate commented 7 months ago

I think I just ran into this issue. First, I tried the obvious thing:

terraform import vultr_kuberenets.my_cluster <uuid copied from browser URL>

This was successful, but then after I ran terraform plan, it started complaining that the cluster must be replaced. Upon further inspection, I found out that some fields in the state file were null, even though they should have values. In my case, those were:

There might be others as well. I tried digging around in the source code, and found this: https://github.com/vultr/terraform-provider-vultr/blob/master/vultr/resource_vultr_kubernetes.go#L155 . I'm not familiar with the Terraform Provider SDK, but it seems to me that resourceVultrKubernetesRead is not reading all fields, which leads to terraform import saving null values. @optik-aper If my train of thought is correct, let me know and I'll push a PR to deal with the 3 fields above!

FYI, I solved my problem by manually editing the state file and setting the fields as needed. But obviously this is a dirty hack, so think thrice before trying it.