aptible / terraform-provider-aptible

The official Terraform provider for Aptible Deploy
https://registry.terraform.io/providers/aptible/aptible/latest
10 stars 13 forks source link

Fix importing of resources #34

Closed robertfairhead closed 4 years ago

robertfairhead commented 4 years ago

During importing of resources we used the resource's ID from our API as its Terraform ID, but during creation we used other semantic values from the resource.

This caused a problem whereby an imported resource and created resource would differ. For example, if you created a resource in Terraform, then removed it from the state, and imported it back, you would end with a different record.

Adding the Import acceptance helper tests for our resources, highlighted this issue. This is now resolved for all resources.

In addition, during that process, it became clear that our Database Image ID information was not being processed properly. It is now. But, that, in turn caused an issue when the config would leave the version empty. Our API then fills in the default version for the resource, which caused an erroneous diff and suggested change by Terraform to return the version to blank. We now suppress that diff in those cases.

I also updated us to v2 of the Terraform Provider SDK, in an attempt to resolve a bug. It did not do that, I eventually got the correct diff suppression as noted above, but the v2 SDK did highlight a few other errors, particularly when we wrote to fields that did not exist in the schema. Those are now fixed as well.

Upgrading to v2 SDK also required updating to go 1.15.x for the builds, which meant updating the Travis config.


I confirmed all acceptance tests are passing