constellix_a_record and constellix_cname_record fail to import geolocation properties correctly on the latest release. This bug affects the Import methods on both resource types. It may also affect other record types - I've only checked CNAME and A records.
Replicate (1)
On release v0.3.5 (commit 4e5aefac597661bfc6ab09a533d0f73a029ed4bf)
Use the following Terraform configuration to provision a domain and record:
Run terraform show and note that the geolocation block is not populated. terraform plan will say that changes are required to the existing infrastructure to add geolocation properties.
Replicate (2)
Modify constellix/resource_constellix_cname_record_test.go and add a geo_location object to the HCL string in the testAccCheckConstellixCNameConfig_basic method. Pipe the following to git-apply
and run the TestAccCName_Basic test. You'll note the test fails, complaining of nonempty plan output for the newly created resource.
=== RUN TestAccCName_Basic
--- FAIL: TestAccCName_Basic (23.85s)
testing.go:684: Step 0 error: After applying this step, the plan was not empty:
Root cause
I think the root cause of this problem is that the schema for the geolocation block is defined incorrectly for both A and CNAME record types. It's declared as TypeMap, but uses the Elem block to define specific keys. According to the Terraform docs this is a misconfiguration. To enforce type constraints on predefined keys, use TypeSet. PR #14 fixes the import behavior by changing the geolocation field to TypeSet, but is backwards incompatible.
Description
constellix_a_record
andconstellix_cname_record
fail to import geolocation properties correctly on the latest release. This bug affects the Import methods on both resource types. It may also affect other record types - I've only checked CNAME and A records.Replicate (1)
On release v0.3.5 (commit 4e5aefac597661bfc6ab09a533d0f73a029ed4bf)
Use the following Terraform configuration to provision a domain and record:
After provisioning the resources, retrieve the CNAME record's ID and remove the resource from Terraform state:
$ terraform state rm constellix_cname_record.replicate1 <ID OF CNAME RECORD>
The resource is now untracked. Import it back into state.
$ terraform import constellix_cname_record.replicate1 domains:<DOMAIN ID>:<CNAME ID>
Run
terraform show
and note that the geolocation block is not populated.terraform plan
will say that changes are required to the existing infrastructure to add geolocation properties.Replicate (2)
Modify
constellix/resource_constellix_cname_record_test.go
and add ageo_location
object to the HCL string in thetestAccCheckConstellixCNameConfig_basic
method. Pipe the following to git-applyand run the
TestAccCName_Basic
test. You'll note the test fails, complaining of nonempty plan output for the newly created resource.Root cause
I think the root cause of this problem is that the schema for the geolocation block is defined incorrectly for both A and CNAME record types. It's declared as
TypeMap
, but uses theElem
block to define specific keys. According to the Terraform docs this is a misconfiguration. To enforce type constraints on predefined keys, useTypeSet
. PR #14 fixes the import behavior by changing the geolocation field toTypeSet
, but is backwards incompatible.