From 6b5138328f304607a3b809ffabba374cb7fe7a9b Mon Sep 17 00:00:00 2001 From: Luke Amdor Date: Wed, 22 Apr 2015 13:27:20 -0500 Subject: [PATCH 1/2] changing route53_zone.name_servers back to list --- builtin/providers/aws/resource_aws_route53_zone.go | 6 +----- builtin/providers/aws/resource_aws_route53_zone_test.go | 5 ++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/builtin/providers/aws/resource_aws_route53_zone.go b/builtin/providers/aws/resource_aws_route53_zone.go index 5c55fb3e1..c81322a79 100644 --- a/builtin/providers/aws/resource_aws_route53_zone.go +++ b/builtin/providers/aws/resource_aws_route53_zone.go @@ -6,7 +6,6 @@ import ( "strings" "time" - "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/schema" @@ -34,12 +33,9 @@ func resourceAwsRoute53Zone() *schema.Resource { }, "name_servers": &schema.Schema{ - Type: schema.TypeSet, + Type: schema.TypeList, Elem: &schema.Schema{Type: schema.TypeString}, Computed: true, - Set: func(v interface{}) int { - return hashcode.String(v.(string)) - }, }, "tags": tagsSchema(), diff --git a/builtin/providers/aws/resource_aws_route53_zone_test.go b/builtin/providers/aws/resource_aws_route53_zone_test.go index 4686831e0..f4a1afb0c 100644 --- a/builtin/providers/aws/resource_aws_route53_zone_test.go +++ b/builtin/providers/aws/resource_aws_route53_zone_test.go @@ -4,7 +4,6 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" @@ -116,8 +115,8 @@ func testAccCheckRoute53ZoneExists(n string, zone *route53.HostedZone) resource. return fmt.Errorf("Hosted zone err: %v", err) } - for _, ns := range resp.DelegationSet.NameServers { - attribute := fmt.Sprintf("name_servers.%d", hashcode.String(*ns)) + for idx, ns := range resp.DelegationSet.NameServers { + 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) From fe2d9ea3cc486b1354d417af7172e0372627ca6a Mon Sep 17 00:00:00 2001 From: Luke Amdor Date: Thu, 23 Apr 2015 08:48:19 -0500 Subject: [PATCH 2/2] sorting the name_server entries --- builtin/providers/aws/resource_aws_route53_zone.go | 2 ++ .../providers/aws/resource_aws_route53_zone_test.go | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/resource_aws_route53_zone.go b/builtin/providers/aws/resource_aws_route53_zone.go index c81322a79..59937fbc0 100644 --- a/builtin/providers/aws/resource_aws_route53_zone.go +++ b/builtin/providers/aws/resource_aws_route53_zone.go @@ -3,6 +3,7 @@ package aws import ( "fmt" "log" + "sort" "strings" "time" @@ -101,6 +102,7 @@ func resourceAwsRoute53ZoneRead(d *schema.ResourceData, meta interface{}) error 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) } diff --git a/builtin/providers/aws/resource_aws_route53_zone_test.go b/builtin/providers/aws/resource_aws_route53_zone_test.go index f4a1afb0c..0a32cb2cd 100644 --- a/builtin/providers/aws/resource_aws_route53_zone_test.go +++ b/builtin/providers/aws/resource_aws_route53_zone_test.go @@ -2,6 +2,7 @@ package aws import ( "fmt" + "sort" "testing" "github.com/hashicorp/terraform/helper/resource" @@ -115,10 +116,15 @@ func testAccCheckRoute53ZoneExists(n string, zone *route53.HostedZone) resource. return fmt.Errorf("Hosted zone err: %v", err) } - for idx, ns := range resp.DelegationSet.NameServers { + 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 { + if dsns != ns { return fmt.Errorf("Got: %v for %v, Expected: %v", dsns, attribute, ns) } }