bluecatlabs/terraform-provider-bluecat

Provider does not follow best practices

adarobin opened this issue · 0 comments

From the HashiCorp Design Principles:

A Terraform resource should offer support for terraform import.

One of the first things I tried to do when I started investigating this provider was import an existing IP Address. I was disappointed to discover that none of the resources seem to support import.

A Terraform resource should be a declarative representation of single component, usually with create, read, delete, and optionally update methods. In general, abstractions of multiple components or advanced behaviors in Terraform should be accomplished via Terraform Modules, potentially hosted in the Terraform Registry.

For example, a bluecat_ip_allocation is a weird combination of an IP Address and a Host Record.

The last one I couldn't find in the design principles, but it is referenced in one of their tutorials:

When you create something in Terraform but delete it manually, Terraform should gracefully handle it. If the API returns an error when the resource doesn't exist, the read function should check to see if the resource is available first. If the resource isn't available, the function should set the ID to an empty string so Terraform "destroys" the resource in state.

This makes using the provider a complete show stopper for me. Consider this example code:

resource "bluecat_ip_allocation" "test" {
  zone    = "example.com"
  name    = "test"
  network = "10.0.0.0/24"
}

Let's say it resulted in me being given the IP Address 10.0.0.2. If someone were to go into the BlueCat Address Manager and delete this address I would be greeted with this the next time I ran Terraform:

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Getting IP address 10.0.0.2 failed: ID of the object is 0
│ 
│   with bluecat_ip_allocation.test,
│   on main.tf line 1, in resource "bluecat_ip_allocation" "test":
│    1: resource "bluecat_ip_allocation" "test" {
│ 
╵

I have to manually remove the resource from the state file (terraform state rm bluecat_ip_allocation.test) to continue - even if the block in question is deleted.