dnsimple / terraform-provider-dnsimple

Terraform DNSimple provider.
https://www.terraform.io/docs/providers/dnsimple/
Mozilla Public License 2.0
22 stars 20 forks source link

Records with underscores in the name cannot be imported #7

Closed logicbomb421 closed 1 year ago

logicbomb421 commented 6 years ago

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform v0.11.1

Affected Resource(s)

Terraform Configuration Files

resource "dnssimple_record" "domain" {}

also via cli: terraform import dnsimple_record.domain _mydomain.com_1234

Expected Behavior

The record is imported into the terraform state.

Actual Behavior

Received the following:

Error importing: 1 error(s) occurred:
* dnsimple_record.domain (import id: _mydomain.com_1234): import dnsimple_record.domain (id:_mydomain.com_1234): Error Importing dnsimple_record. Please make sure the record ID is in the form DOMAIN_RECORDID (i.e. example.com_1234

Steps to Reproduce

  1. Create a DNSimple record with an underscore in it (e.g. my_domain.example.com)
  2. Create a dnsimple_record resource to import into
  3. Run the import step as described in the provider documentation

Important Factoids

The issue is in the resourceDNSimpleRecordImport func on line 191 of /dnsimple/resource_dnsimple_record.go. The length check after splitting the input domain on _ expects there to be exactly two parts, when there is the possibility for domains with underscores in them (for instance, AWS ACM certificate validation records begin with an underscore).

Shown here.

jamesarosen commented 5 years ago

Note that this only matters for apex domains with underscores since the ID of the record is [zone]_[id]. I was able to import a record like foo._domainkey.example.com CNAME … just fine via terraform import dnsimple_record.foo_dkim example.com_12345678.