diff --git a/builtin/providers/aws/resource_aws_route53_record.go b/builtin/providers/aws/resource_aws_route53_record.go index 71ddff056..3a8ef2e5c 100644 --- a/builtin/providers/aws/resource_aws_route53_record.go +++ b/builtin/providers/aws/resource_aws_route53_record.go @@ -184,7 +184,10 @@ func resourceAwsRoute53RecordRead(d *schema.ResourceData, meta interface{}) erro found = true - d.Set("records", record.ResourceRecords) + err := d.Set("records", flattenResourceRecords(record.ResourceRecords)) + if err != nil { + log.Printf("[DEBUG] Error setting records for: %s, error: %#v", en, err) + } d.Set("ttl", record.TTL) break diff --git a/builtin/providers/aws/structure.go b/builtin/providers/aws/structure.go index 7a36f5304..b4ff209d6 100644 --- a/builtin/providers/aws/structure.go +++ b/builtin/providers/aws/structure.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/aws-sdk-go/gen/ec2" "github.com/hashicorp/aws-sdk-go/gen/elb" "github.com/hashicorp/aws-sdk-go/gen/rds" + "github.com/hashicorp/aws-sdk-go/gen/route53" "github.com/hashicorp/terraform/helper/schema" ) @@ -251,3 +252,11 @@ func flattenAttachment(a *ec2.NetworkInterfaceAttachment) map[string]interface{} att["attachment_id"] = *a.AttachmentID return att } + +func flattenResourceRecords(recs []route53.ResourceRecord) []string { + strs := make([]string, 0, len(recs)) + for _, r := range recs { + strs = append(strs, *r.Value) + } + return strs +} diff --git a/builtin/providers/aws/structure_test.go b/builtin/providers/aws/structure_test.go index aafdeabbc..ca27f6ddf 100644 --- a/builtin/providers/aws/structure_test.go +++ b/builtin/providers/aws/structure_test.go @@ -8,6 +8,7 @@ import ( ec2 "github.com/hashicorp/aws-sdk-go/gen/ec2" "github.com/hashicorp/aws-sdk-go/gen/elb" "github.com/hashicorp/aws-sdk-go/gen/rds" + "github.com/hashicorp/aws-sdk-go/gen/route53" "github.com/hashicorp/terraform/flatmap" "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" @@ -442,3 +443,24 @@ func TestFlattenAttachment(t *testing.T) { t.Fatalf("expected attachment_id to be at-002, but got %s", result["attachment_id"]) } } + +func TestFlattenResourceRecords(t *testing.T) { + expanded := []route53.ResourceRecord{ + route53.ResourceRecord{ + Value: aws.String("127.0.0.1"), + }, + route53.ResourceRecord{ + Value: aws.String("127.0.0.3"), + }, + } + + result := flattenResourceRecords(expanded) + + if result == nil { + t.Fatal("expected result to have value, but got nil") + } + + if len(result) != 2 { + t.Fatal("expected result to have value, but got nil") + } +}