From a51bc6007dcad83c567c6644e58f54c378ba077a Mon Sep 17 00:00:00 2001 From: John Engelman Date: Fri, 8 May 2015 08:58:35 -0500 Subject: [PATCH] DelegationSet is not support in private zones. --- .../aws/resource_aws_route53_zone.go | 20 ++++++++++------- .../aws/resource_aws_route53_zone_test.go | 22 ++++++++++--------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/builtin/providers/aws/resource_aws_route53_zone.go b/builtin/providers/aws/resource_aws_route53_zone.go index d8f688e74..e89b782c0 100644 --- a/builtin/providers/aws/resource_aws_route53_zone.go +++ b/builtin/providers/aws/resource_aws_route53_zone.go @@ -70,7 +70,7 @@ func resourceAwsRoute53ZoneCreate(d *schema.ResourceData, meta interface{}) erro VPCID: aws.String(v.(string)), VPCRegion: aws.String(meta.(*AWSClient).region), } - if w := d.Get("vpc_region"); w != nil { + if w := d.Get("vpc_region"); w != "" { req.VPC.VPCRegion = aws.String(w.(string)) } } @@ -119,13 +119,17 @@ func resourceAwsRoute53ZoneRead(d *schema.ResourceData, meta interface{}) error return err } - ns := make([]string, len(zone.DelegationSet.NameServers)) - for i := range zone.DelegationSet.NameServers { - ns[i] = *zone.DelegationSet.NameServers[i] - } - sort.Strings(ns) - if err := d.Set("name_servers", ns); err != nil { - return fmt.Errorf("[DEBUG] Error setting name servers for: %s, error: %#v", d.Id(), err) + if zone.DelegationSet != nil { + ns := make([]string, len(zone.DelegationSet.NameServers)) + for i := range zone.DelegationSet.NameServers { + ns[i] = *zone.DelegationSet.NameServers[i] + } + sort.Strings(ns) + if err := d.Set("name_servers", ns); err != nil { + return fmt.Errorf("[DEBUG] Error setting name servers for: %s, error: %#v", d.Id(), err) + } + } else { + d.Set("name_servers", nil); } // get tags diff --git a/builtin/providers/aws/resource_aws_route53_zone_test.go b/builtin/providers/aws/resource_aws_route53_zone_test.go index 12ab623d3..0fda00815 100644 --- a/builtin/providers/aws/resource_aws_route53_zone_test.go +++ b/builtin/providers/aws/resource_aws_route53_zone_test.go @@ -134,16 +134,18 @@ func testAccCheckRoute53ZoneExists(n string, zone *route53.HostedZone) resource. return fmt.Errorf("Hosted zone err: %v", err) } - sorted_ns := make([]string, len(resp.DelegationSet.NameServers)) - for i, ns := range resp.DelegationSet.NameServers { - sorted_ns[i] = *ns - } - sort.Strings(sorted_ns) - for idx, ns := range sorted_ns { - attribute := fmt.Sprintf("name_servers.%d", idx) - dsns := rs.Primary.Attributes[attribute] - if dsns != ns { - return fmt.Errorf("Got: %v for %v, Expected: %v", dsns, attribute, ns) + if resp.DelegationSet != nil { + sorted_ns := make([]string, len(resp.DelegationSet.NameServers)) + for i, ns := range resp.DelegationSet.NameServers { + sorted_ns[i] = *ns + } + sort.Strings(sorted_ns) + for idx, ns := range sorted_ns { + attribute := fmt.Sprintf("name_servers.%d", idx) + dsns := rs.Primary.Attributes[attribute] + if dsns != ns { + return fmt.Errorf("Got: %v for %v, Expected: %v", dsns, attribute, ns) + } } }