Fixing the flipflop problem

Actually meant as a PoC, but it works perfectly so let’s just merge
this…
This commit is contained in:
Sander van Harmelen 2014-12-16 00:40:43 +01:00
parent 820476ef61
commit ee7b33acf4
1 changed files with 16 additions and 4 deletions

View File

@ -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