using a set for route53 name_servers

This commit is contained in:
Luke Amdor 2015-04-15 16:10:02 -05:00
parent 46d3ab5ccd
commit f8b05fa05e
2 changed files with 8 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
@ -33,9 +34,12 @@ func resourceAwsRoute53Zone() *schema.Resource {
}, },
"name_servers": &schema.Schema{ "name_servers": &schema.Schema{
Type: schema.TypeList, Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
Computed: true, Computed: true,
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
}, },
"tags": tagsSchema(), "tags": tagsSchema(),

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
@ -115,8 +116,8 @@ func testAccCheckRoute53ZoneExists(n string, zone *route53.HostedZone) resource.
return fmt.Errorf("Hosted zone err: %v", err) return fmt.Errorf("Hosted zone err: %v", err)
} }
for i, ns := range resp.DelegationSet.NameServers { for _, ns := range resp.DelegationSet.NameServers {
attribute := fmt.Sprintf("name_servers.%d", i) attribute := fmt.Sprintf("name_servers.%d", hashcode.String(ns))
dsns := rs.Primary.Attributes[attribute] dsns := rs.Primary.Attributes[attribute]
if dsns != ns { if dsns != ns {
return fmt.Errorf("Got: %v for %v, Expected: %v", dsns, attribute, ns) return fmt.Errorf("Got: %v for %v, Expected: %v", dsns, attribute, ns)