From ee7b33acf4b53426754aa26a0875f3e4338361d7 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Tue, 16 Dec 2014 00:40:43 +0100 Subject: [PATCH] Fixing the flipflop problem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Actually meant as a PoC, but it works perfectly so let’s just merge this… --- .../aws/resource_aws_route53_record.go | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/builtin/providers/aws/resource_aws_route53_record.go b/builtin/providers/aws/resource_aws_route53_record.go index 167405e9d..7c9b62f5e 100644 --- a/builtin/providers/aws/resource_aws_route53_record.go +++ b/builtin/providers/aws/resource_aws_route53_record.go @@ -6,6 +6,7 @@ import ( "strings" "time" + "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/schema" "github.com/mitchellh/goamz/route53" @@ -43,10 +44,13 @@ func resourceAwsRoute53Record() *schema.Resource { }, "records": &schema.Schema{ - Type: schema.TypeList, + Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Required: true, ForceNew: true, + Set: func(v interface{}) int { + return hashcode.String(v.(string)) + }, }, }, } @@ -151,10 +155,18 @@ func resourceAwsRoute53RecordRead(d *schema.ResourceData, meta interface{}) erro found = true - for i, rec := range record.Records { - key := fmt.Sprintf("records.%d", i) - d.Set(key, rec) + // Create an empty schema.Set to hold all found records + records := &schema.Set{ + F: func(v interface{}) int { + return hashcode.String(v.(string)) + }, } + + for _, rec := range record.Records { + records.Add(rec) + } + + d.Set("records", records) d.Set("ttl", record.TTL) break