From 5458c54df69b22079b45acf26196d629d3ac32c0 Mon Sep 17 00:00:00 2001 From: Vincent Roseberry Date: Wed, 15 Nov 2017 17:09:01 -0800 Subject: [PATCH 1/6] Add import support to google_dns_record_set --- google/resource_dns_record_set.go | 30 +++++++++++++++--- google/resource_dns_record_set_test.go | 43 ++++++++++++++++---------- website/docs/r/dns_record_set.markdown | 11 ++++++- 3 files changed, 61 insertions(+), 23 deletions(-) diff --git a/google/resource_dns_record_set.go b/google/resource_dns_record_set.go index 812e79979d5..bfae11cb316 100644 --- a/google/resource_dns_record_set.go +++ b/google/resource_dns_record_set.go @@ -6,6 +6,7 @@ import ( "github.com/hashicorp/terraform/helper/schema" "google.golang.org/api/dns/v1" + "strings" ) func resourceDnsRecordSet() *schema.Resource { @@ -14,6 +15,9 @@ func resourceDnsRecordSet() *schema.Resource { Read: resourceDnsRecordSetRead, Delete: resourceDnsRecordSetDelete, Update: resourceDnsRecordSetUpdate, + Importer: &schema.ResourceImporter{ + State: resourceDnsRecordSetImportState, + }, Schema: map[string]*schema.Schema{ "managed_zone": &schema.Schema{ @@ -64,14 +68,16 @@ func resourceDnsRecordSetCreate(d *schema.ResourceData, meta interface{}) error return err } + name := d.Get("name").(string) zone := d.Get("managed_zone").(string) + rType := d.Get("type").(string) // Build the change chg := &dns.Change{ Additions: []*dns.ResourceRecordSet{ &dns.ResourceRecordSet{ - Name: d.Get("name").(string), - Type: d.Get("type").(string), + Name: name, + Type: rType, Ttl: int64(d.Get("ttl").(int)), Rrdatas: rrdata(d), }, @@ -86,7 +92,7 @@ func resourceDnsRecordSetCreate(d *schema.ResourceData, meta interface{}) error // We also can't just remove the NS recordsets on creation, as at // least one is required. So the solution is to "update in place" by // putting the addition and the removal in the same API call. - if d.Get("type").(string) == "NS" { + if rType == "NS" { log.Printf("[DEBUG] DNS record list request for %q", zone) res, err := config.clientDns.ResourceRecordSets.List(project, zone).Do() if err != nil { @@ -95,7 +101,7 @@ func resourceDnsRecordSetCreate(d *schema.ResourceData, meta interface{}) error var deletions []*dns.ResourceRecordSet for _, record := range res.Rrsets { - if record.Type != "NS" || record.Name != d.Get("name").(string) { + if record.Type != "NS" || record.Name != name { continue } deletions = append(deletions, record) @@ -111,7 +117,7 @@ func resourceDnsRecordSetCreate(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error creating DNS RecordSet: %s", err) } - d.SetId(chg.Id) + d.SetId(fmt.Sprintf("%s/%s/%s", zone, name, rType)) w := &DnsChangeWaiter{ Service: config.clientDns, @@ -156,6 +162,7 @@ func resourceDnsRecordSetRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Only expected 1 record set, got %d", len(resp.Rrsets)) } + d.Set("type", resp.Rrsets[0].Type) d.Set("ttl", resp.Rrsets[0].Ttl) d.Set("rrdatas", resp.Rrsets[0].Rrdatas) d.Set("project", project) @@ -286,6 +293,19 @@ func resourceDnsRecordSetUpdate(d *schema.ResourceData, meta interface{}) error return resourceDnsRecordSetRead(d, meta) } +func resourceDnsRecordSetImportState(d *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) { + parts := strings.Split(d.Id(), "/") + if len(parts) != 3 { + return nil, fmt.Errorf("Invalid dns record specifier. Expecting {zone-name}/{record-set-name}/{record-type}") + } + + d.Set("managed_zone", parts[0]) + d.Set("name", parts[1]) + d.Set("type", parts[2]) + + return []*schema.ResourceData{d}, nil +} + func rrdata( d *schema.ResourceData, ) []string { diff --git a/google/resource_dns_record_set_test.go b/google/resource_dns_record_set_test.go index f4553634e98..e1c27f1fdf0 100644 --- a/google/resource_dns_record_set_test.go +++ b/google/resource_dns_record_set_test.go @@ -12,19 +12,26 @@ import ( func TestAccDnsRecordSet_basic(t *testing.T) { t.Parallel() - zoneName := fmt.Sprintf("dnszone-test-%s", acctest.RandString(10)) + zoneName := acctest.RandomWithPrefix("dnszone-test") + recordName := acctest.RandomWithPrefix("record-test") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckDnsRecordSetDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccDnsRecordSet_basic(zoneName, "127.0.0.10", 300), + Config: testAccDnsRecordSet_basic(zoneName, recordName, "127.0.0.10", 300), Check: resource.ComposeTestCheckFunc( testAccCheckDnsRecordSetExists( "google_dns_record_set.foobar", zoneName), ), }, + resource.TestStep{ + ResourceName: "google_dns_record_set.foobar", + ImportStateId: fmt.Sprintf("%s/%s.hashicorptest.com./A", zoneName, recordName), + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -32,28 +39,29 @@ func TestAccDnsRecordSet_basic(t *testing.T) { func TestAccDnsRecordSet_modify(t *testing.T) { t.Parallel() - zoneName := fmt.Sprintf("dnszone-test-%s", acctest.RandString(10)) + zoneName := acctest.RandomWithPrefix("dnszone-test") + recordName := acctest.RandomWithPrefix("record-test") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckDnsRecordSetDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccDnsRecordSet_basic(zoneName, "127.0.0.10", 300), + Config: testAccDnsRecordSet_basic(zoneName, recordName, "127.0.0.10", 300), Check: resource.ComposeTestCheckFunc( testAccCheckDnsRecordSetExists( "google_dns_record_set.foobar", zoneName), ), }, resource.TestStep{ - Config: testAccDnsRecordSet_basic(zoneName, "127.0.0.11", 300), + Config: testAccDnsRecordSet_basic(zoneName, recordName, "127.0.0.11", 300), Check: resource.ComposeTestCheckFunc( testAccCheckDnsRecordSetExists( "google_dns_record_set.foobar", zoneName), ), }, resource.TestStep{ - Config: testAccDnsRecordSet_basic(zoneName, "127.0.0.11", 600), + Config: testAccDnsRecordSet_basic(zoneName, recordName, "127.0.0.11", 600), Check: resource.ComposeTestCheckFunc( testAccCheckDnsRecordSetExists( "google_dns_record_set.foobar", zoneName), @@ -66,21 +74,22 @@ func TestAccDnsRecordSet_modify(t *testing.T) { func TestAccDnsRecordSet_changeType(t *testing.T) { t.Parallel() - zoneName := fmt.Sprintf("dnszone-test-%s", acctest.RandString(10)) + zoneName := acctest.RandomWithPrefix("dnszone-test") + recordName := acctest.RandomWithPrefix("record-test") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckDnsRecordSetDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccDnsRecordSet_basic(zoneName, "127.0.0.10", 300), + Config: testAccDnsRecordSet_basic(zoneName, recordName, "127.0.0.10", 300), Check: resource.ComposeTestCheckFunc( testAccCheckDnsRecordSetExists( "google_dns_record_set.foobar", zoneName), ), }, resource.TestStep{ - Config: testAccDnsRecordSet_bigChange(zoneName, 600), + Config: testAccDnsRecordSet_bigChange(zoneName, recordName, 600), Check: resource.ComposeTestCheckFunc( testAccCheckDnsRecordSetExists( "google_dns_record_set.foobar", zoneName), @@ -91,7 +100,7 @@ func TestAccDnsRecordSet_changeType(t *testing.T) { } func TestAccDnsRecordSet_ns(t *testing.T) { - zoneName := fmt.Sprintf("dnszone-test-ns-%s", acctest.RandString(10)) + zoneName := acctest.RandomWithPrefix("dnszone-test") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -176,7 +185,7 @@ func testAccCheckDnsRecordSetExists(resourceType, resourceName string) resource. } } -func testAccDnsRecordSet_basic(zoneName string, addr2 string, ttl int) string { +func testAccDnsRecordSet_basic(zoneName, recordName, addr2 string, ttl int) string { return fmt.Sprintf(` resource "google_dns_managed_zone" "parent-zone" { name = "%s" @@ -185,12 +194,12 @@ func testAccDnsRecordSet_basic(zoneName string, addr2 string, ttl int) string { } resource "google_dns_record_set" "foobar" { managed_zone = "${google_dns_managed_zone.parent-zone.name}" - name = "test-record.hashicorptest.com." + name = "%s.${google_dns_managed_zone.parent-zone.dns_name}" type = "A" rrdatas = ["127.0.0.1", "%s"] ttl = %d } - `, zoneName, addr2, ttl) + `, zoneName, recordName, addr2, ttl) } func testAccDnsRecordSet_ns(name string, ttl int) string { @@ -202,7 +211,7 @@ func testAccDnsRecordSet_ns(name string, ttl int) string { } resource "google_dns_record_set" "foobar" { managed_zone = "${google_dns_managed_zone.parent-zone.name}" - name = "hashicorptest.com." + name = "${google_dns_managed_zone.parent-zone.dns_name}" type = "NS" rrdatas = ["ns.hashicorp.services.", "ns2.hashicorp.services."] ttl = %d @@ -227,7 +236,7 @@ func testAccDnsRecordSet_nestedNS(name string, ttl int) string { `, name, ttl) } -func testAccDnsRecordSet_bigChange(zoneName string, ttl int) string { +func testAccDnsRecordSet_bigChange(zoneName, recordName string, ttl int) string { return fmt.Sprintf(` resource "google_dns_managed_zone" "parent-zone" { name = "%s" @@ -236,10 +245,10 @@ func testAccDnsRecordSet_bigChange(zoneName string, ttl int) string { } resource "google_dns_record_set" "foobar" { managed_zone = "${google_dns_managed_zone.parent-zone.name}" - name = "test-record.hashicorptest.com." + name = "%s.${google_dns_managed_zone.parent-zone.dns_name}" type = "CNAME" rrdatas = ["www.terraform.io."] ttl = %d } - `, zoneName, ttl) + `, zoneName, recordName, ttl) } diff --git a/website/docs/r/dns_record_set.markdown b/website/docs/r/dns_record_set.markdown index 5e18c0485a9..7810d824634 100644 --- a/website/docs/r/dns_record_set.markdown +++ b/website/docs/r/dns_record_set.markdown @@ -8,7 +8,8 @@ description: |- # google\_dns\_record\_set -Manages a set of DNS records within Google Cloud DNS. +Manages a set of DNS records within Google Cloud DNS. For more information see [the official documentation](https://cloud.google.com/dns/records/) and +[API](https://cloud.google.com/dns/api/v1/resourceRecordSets). ~> **Note:** The Google Cloud DNS API requires NS records be present at all times. To accommodate this, when creating NS records, the default records @@ -98,3 +99,11 @@ The following arguments are supported: ## Attributes Reference Only the arguments listed above are exposed as attributes. + +## Import + +DNS record set can be imported using the zone `name`, record `name` and record `type`, e.g. + +``` +$ terraform import google_dns_record_set.frontend prod-zone/frontend.prod.mydomain.com./A +``` From 5882ce246f475aec85138913dcc932a23a3d2311 Mon Sep 17 00:00:00 2001 From: Vincent Roseberry Date: Fri, 22 Dec 2017 13:35:32 -0800 Subject: [PATCH 2/6] Add import test to NS record --- google/resource_dns_record_set_test.go | 35 ++++++++++++++------------ 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/google/resource_dns_record_set_test.go b/google/resource_dns_record_set_test.go index e1c27f1fdf0..fea67792c2e 100644 --- a/google/resource_dns_record_set_test.go +++ b/google/resource_dns_record_set_test.go @@ -13,14 +13,13 @@ func TestAccDnsRecordSet_basic(t *testing.T) { t.Parallel() zoneName := acctest.RandomWithPrefix("dnszone-test") - recordName := acctest.RandomWithPrefix("record-test") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckDnsRecordSetDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccDnsRecordSet_basic(zoneName, recordName, "127.0.0.10", 300), + Config: testAccDnsRecordSet_basic(zoneName, "127.0.0.10", 300), Check: resource.ComposeTestCheckFunc( testAccCheckDnsRecordSetExists( "google_dns_record_set.foobar", zoneName), @@ -28,7 +27,7 @@ func TestAccDnsRecordSet_basic(t *testing.T) { }, resource.TestStep{ ResourceName: "google_dns_record_set.foobar", - ImportStateId: fmt.Sprintf("%s/%s.hashicorptest.com./A", zoneName, recordName), + ImportStateId: fmt.Sprintf("%s/test-record.hashicorptest.com./A", zoneName), ImportState: true, ImportStateVerify: true, }, @@ -40,28 +39,27 @@ func TestAccDnsRecordSet_modify(t *testing.T) { t.Parallel() zoneName := acctest.RandomWithPrefix("dnszone-test") - recordName := acctest.RandomWithPrefix("record-test") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckDnsRecordSetDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccDnsRecordSet_basic(zoneName, recordName, "127.0.0.10", 300), + Config: testAccDnsRecordSet_basic(zoneName, "127.0.0.10", 300), Check: resource.ComposeTestCheckFunc( testAccCheckDnsRecordSetExists( "google_dns_record_set.foobar", zoneName), ), }, resource.TestStep{ - Config: testAccDnsRecordSet_basic(zoneName, recordName, "127.0.0.11", 300), + Config: testAccDnsRecordSet_basic(zoneName, "127.0.0.11", 300), Check: resource.ComposeTestCheckFunc( testAccCheckDnsRecordSetExists( "google_dns_record_set.foobar", zoneName), ), }, resource.TestStep{ - Config: testAccDnsRecordSet_basic(zoneName, recordName, "127.0.0.11", 600), + Config: testAccDnsRecordSet_basic(zoneName, "127.0.0.11", 600), Check: resource.ComposeTestCheckFunc( testAccCheckDnsRecordSetExists( "google_dns_record_set.foobar", zoneName), @@ -75,21 +73,20 @@ func TestAccDnsRecordSet_changeType(t *testing.T) { t.Parallel() zoneName := acctest.RandomWithPrefix("dnszone-test") - recordName := acctest.RandomWithPrefix("record-test") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckDnsRecordSetDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccDnsRecordSet_basic(zoneName, recordName, "127.0.0.10", 300), + Config: testAccDnsRecordSet_basic(zoneName, "127.0.0.10", 300), Check: resource.ComposeTestCheckFunc( testAccCheckDnsRecordSetExists( "google_dns_record_set.foobar", zoneName), ), }, resource.TestStep{ - Config: testAccDnsRecordSet_bigChange(zoneName, recordName, 600), + Config: testAccDnsRecordSet_bigChange(zoneName, 600), Check: resource.ComposeTestCheckFunc( testAccCheckDnsRecordSetExists( "google_dns_record_set.foobar", zoneName), @@ -113,6 +110,12 @@ func TestAccDnsRecordSet_ns(t *testing.T) { "google_dns_record_set.foobar", zoneName), ), }, + resource.TestStep{ + ResourceName: "google_dns_record_set.foobar", + ImportStateId: fmt.Sprintf("%s/hashicorptest.com./NS", zoneName), + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -185,7 +188,7 @@ func testAccCheckDnsRecordSetExists(resourceType, resourceName string) resource. } } -func testAccDnsRecordSet_basic(zoneName, recordName, addr2 string, ttl int) string { +func testAccDnsRecordSet_basic(zoneName, addr2 string, ttl int) string { return fmt.Sprintf(` resource "google_dns_managed_zone" "parent-zone" { name = "%s" @@ -194,12 +197,12 @@ func testAccDnsRecordSet_basic(zoneName, recordName, addr2 string, ttl int) stri } resource "google_dns_record_set" "foobar" { managed_zone = "${google_dns_managed_zone.parent-zone.name}" - name = "%s.${google_dns_managed_zone.parent-zone.dns_name}" + name = "test-record.${google_dns_managed_zone.parent-zone.dns_name}" type = "A" rrdatas = ["127.0.0.1", "%s"] ttl = %d } - `, zoneName, recordName, addr2, ttl) + `, zoneName, addr2, ttl) } func testAccDnsRecordSet_ns(name string, ttl int) string { @@ -236,7 +239,7 @@ func testAccDnsRecordSet_nestedNS(name string, ttl int) string { `, name, ttl) } -func testAccDnsRecordSet_bigChange(zoneName, recordName string, ttl int) string { +func testAccDnsRecordSet_bigChange(zoneName string, ttl int) string { return fmt.Sprintf(` resource "google_dns_managed_zone" "parent-zone" { name = "%s" @@ -245,10 +248,10 @@ func testAccDnsRecordSet_bigChange(zoneName, recordName string, ttl int) string } resource "google_dns_record_set" "foobar" { managed_zone = "${google_dns_managed_zone.parent-zone.name}" - name = "%s.${google_dns_managed_zone.parent-zone.dns_name}" + name = "test-record.${google_dns_managed_zone.parent-zone.dns_name}" type = "CNAME" rrdatas = ["www.terraform.io."] ttl = %d } - `, zoneName, recordName, ttl) + `, zoneName, ttl) } From 661ca006e896f5329cacff5fae8fe567d4503917 Mon Sep 17 00:00:00 2001 From: Vincent Roseberry Date: Fri, 22 Dec 2017 17:00:32 -0800 Subject: [PATCH 3/6] Minimize diff change --- google/resource_dns_record_set_test.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/google/resource_dns_record_set_test.go b/google/resource_dns_record_set_test.go index fea67792c2e..33dfd5f1eff 100644 --- a/google/resource_dns_record_set_test.go +++ b/google/resource_dns_record_set_test.go @@ -12,7 +12,7 @@ import ( func TestAccDnsRecordSet_basic(t *testing.T) { t.Parallel() - zoneName := acctest.RandomWithPrefix("dnszone-test") + zoneName := fmt.Sprintf("dnszone-test-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -38,7 +38,7 @@ func TestAccDnsRecordSet_basic(t *testing.T) { func TestAccDnsRecordSet_modify(t *testing.T) { t.Parallel() - zoneName := acctest.RandomWithPrefix("dnszone-test") + zoneName := fmt.Sprintf("dnszone-test-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -72,7 +72,7 @@ func TestAccDnsRecordSet_modify(t *testing.T) { func TestAccDnsRecordSet_changeType(t *testing.T) { t.Parallel() - zoneName := acctest.RandomWithPrefix("dnszone-test") + zoneName := fmt.Sprintf("dnszone-test-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -97,7 +97,9 @@ func TestAccDnsRecordSet_changeType(t *testing.T) { } func TestAccDnsRecordSet_ns(t *testing.T) { - zoneName := acctest.RandomWithPrefix("dnszone-test") + t.Parallel() + + zoneName := fmt.Sprintf("dnszone-test-ns-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -121,6 +123,8 @@ func TestAccDnsRecordSet_ns(t *testing.T) { } func TestAccDnsRecordSet_nestedNS(t *testing.T) { + t.Parallel() + zoneName := fmt.Sprintf("dnszone-test-ns-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -188,7 +192,7 @@ func testAccCheckDnsRecordSetExists(resourceType, resourceName string) resource. } } -func testAccDnsRecordSet_basic(zoneName, addr2 string, ttl int) string { +func testAccDnsRecordSet_basic(zoneName string, addr2 string, ttl int) string { return fmt.Sprintf(` resource "google_dns_managed_zone" "parent-zone" { name = "%s" @@ -197,7 +201,7 @@ func testAccDnsRecordSet_basic(zoneName, addr2 string, ttl int) string { } resource "google_dns_record_set" "foobar" { managed_zone = "${google_dns_managed_zone.parent-zone.name}" - name = "test-record.${google_dns_managed_zone.parent-zone.dns_name}" + name = "test-record.hashicorptest.com." type = "A" rrdatas = ["127.0.0.1", "%s"] ttl = %d @@ -214,7 +218,7 @@ func testAccDnsRecordSet_ns(name string, ttl int) string { } resource "google_dns_record_set" "foobar" { managed_zone = "${google_dns_managed_zone.parent-zone.name}" - name = "${google_dns_managed_zone.parent-zone.dns_name}" + name = "hashicorptest.com." type = "NS" rrdatas = ["ns.hashicorp.services.", "ns2.hashicorp.services."] ttl = %d @@ -248,7 +252,7 @@ func testAccDnsRecordSet_bigChange(zoneName string, ttl int) string { } resource "google_dns_record_set" "foobar" { managed_zone = "${google_dns_managed_zone.parent-zone.name}" - name = "test-record.${google_dns_managed_zone.parent-zone.dns_name}" + name = "test-record.hashicorptest.com." type = "CNAME" rrdatas = ["www.terraform.io."] ttl = %d From af72d1f7bbacfa58f1074a3c647a2ab065fbe1ce Mon Sep 17 00:00:00 2001 From: Vincent Roseberry Date: Wed, 17 Jan 2018 10:46:05 -0800 Subject: [PATCH 4/6] Improve docs --- google/resource_dns_record_set.go | 2 +- website/docs/r/dns_record_set.markdown | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/google/resource_dns_record_set.go b/google/resource_dns_record_set.go index bfae11cb316..8419a9a9e1a 100644 --- a/google/resource_dns_record_set.go +++ b/google/resource_dns_record_set.go @@ -296,7 +296,7 @@ func resourceDnsRecordSetUpdate(d *schema.ResourceData, meta interface{}) error func resourceDnsRecordSetImportState(d *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) { parts := strings.Split(d.Id(), "/") if len(parts) != 3 { - return nil, fmt.Errorf("Invalid dns record specifier. Expecting {zone-name}/{record-set-name}/{record-type}") + return nil, fmt.Errorf("Invalid dns record specifier. Expecting {zone-name}/{record-name}/{record-type}") } d.Set("managed_zone", parts[0]) diff --git a/website/docs/r/dns_record_set.markdown b/website/docs/r/dns_record_set.markdown index 7810d824634..0b5aa46bc6b 100644 --- a/website/docs/r/dns_record_set.markdown +++ b/website/docs/r/dns_record_set.markdown @@ -102,7 +102,7 @@ Only the arguments listed above are exposed as attributes. ## Import -DNS record set can be imported using the zone `name`, record `name` and record `type`, e.g. +DNS record set can be imported using the `zone name`, `record name` and record `type`, e.g. ``` $ terraform import google_dns_record_set.frontend prod-zone/frontend.prod.mydomain.com./A From 76bcc29303679dcfb9ff5a84e3fedfc1ea42344d Mon Sep 17 00:00:00 2001 From: Vincent Roseberry Date: Wed, 17 Jan 2018 11:13:00 -0800 Subject: [PATCH 5/6] Make error message more helpful --- google/resource_dns_record_set.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google/resource_dns_record_set.go b/google/resource_dns_record_set.go index 8419a9a9e1a..12ebfd1b79e 100644 --- a/google/resource_dns_record_set.go +++ b/google/resource_dns_record_set.go @@ -296,7 +296,7 @@ func resourceDnsRecordSetUpdate(d *schema.ResourceData, meta interface{}) error func resourceDnsRecordSetImportState(d *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) { parts := strings.Split(d.Id(), "/") if len(parts) != 3 { - return nil, fmt.Errorf("Invalid dns record specifier. Expecting {zone-name}/{record-name}/{record-type}") + return nil, fmt.Errorf("Invalid dns record specifier. Expecting {zone-name}/{record-name}/{record-type}. The record name must include a trailing '.' at the end.") } d.Set("managed_zone", parts[0]) From a9fcf74bc2a1e00c5c64fdb9c5af01ef11970d15 Mon Sep 17 00:00:00 2001 From: Vincent Roseberry Date: Wed, 17 Jan 2018 11:13:41 -0800 Subject: [PATCH 6/6] Add note about trailing dot at the end of the record name --- website/docs/r/dns_record_set.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/docs/r/dns_record_set.markdown b/website/docs/r/dns_record_set.markdown index 0b5aa46bc6b..1bc18bbcff5 100644 --- a/website/docs/r/dns_record_set.markdown +++ b/website/docs/r/dns_record_set.markdown @@ -107,3 +107,5 @@ DNS record set can be imported using the `zone name`, `record name` and record ` ``` $ terraform import google_dns_record_set.frontend prod-zone/frontend.prod.mydomain.com./A ``` + +Note: The record name must include the trailing dot at the end. \ No newline at end of file