Help with a new Vultr provider

154 views
Skip to first unread message

Rui Lopes

unread,
Jun 22, 2015, 6:30:43 PM6/22/15
to terrafo...@googlegroups.com
Hello,

First of all, I find the terraform project quite interesting, so much, that I'm trying to create a new provider for vultr.com. I've placed my initial effort at https://github.com/rgl/terraform-provider-vultr. Its based on the Digital Ocean provider, but adapted to the Vultr API (using the https://github.com/JamesClonk/vultr library).

I have some doubts though...

Should we expose the resource using the same names as the ones used on the Vultr API? For example, the resource `name` property is actually called `label` on the API. Which one should I use? (in this particular case, I'm using the same name as the vultr library). There are other cases, for example, `ipv4_address` comes from `main_ip`. So, what is the general advice here? just stick with the API names? the library names?

A Vultr server is ready when two attributes have a specific value. The original DO provider code only had code to check for one attribute at a time, so I'm doing this in two steps. First, check the `status` attribute, and then the `power_status`, is this OK? Or maybe the underline library (terraform?) should be changed to support multiple attributes?

When we manually delete a server using the Vultr control panel and we try a terraform destroy, it fails with:

vultr_server.example: Refreshing state... (ID: 2102338)
Error refreshing state: 1 error(s) occurred:

* 1 error(s) occurred:

* Error retrieving server: Invalid server.

How should one recover from this? Manually delete the server from the tfstate file?

TIA!

-- RGL

Paul Hinze

unread,
Jul 10, 2015, 1:29:42 PM7/10/15
to terrafo...@googlegroups.com
Hi there,

Thanks for diving in to this project! I'll answer your questions inline below.

Should we expose the resource using the same names as the ones used on the Vultr API?

Yes, we generally try to stay close to the naming and concepts of the underlying API, unless there is an important UX improvement we need to make.

First, check the `status` attribute, and then the `power_status`, is this OK? 

Yep, this is just fine. We have multiple status fields to check in other resources as well.

When we manually delete a server using the Vultr control panel and we try a terraform destroy, it fails... How should one recover from this?

Generally we respond to "Resource not found" API errors by calling `d.SetId("")` to clear the resource from the state - this way terraform knows that it needs to recreate the resource to apply the configuration.

Hope this helps - let me know if there are any other questions I can help with.

Paul

--
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To post to this group, send email to terrafo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/115dd086-c817-4754-a36e-4987b05db22c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages