From a556c98cde105afb160f65b288113433ff59353b Mon Sep 17 00:00:00 2001 From: stack72 Date: Mon, 30 Nov 2015 12:01:32 +0000 Subject: [PATCH] Adding support for the escapaing of Route53 SPF records --- .../aws/resource_aws_route53_record_test.go | 30 +++++++++++++++++++ builtin/providers/aws/structure.go | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_route53_record_test.go b/builtin/providers/aws/resource_aws_route53_record_test.go index cf063faa8..94dfe8e4b 100644 --- a/builtin/providers/aws/resource_aws_route53_record_test.go +++ b/builtin/providers/aws/resource_aws_route53_record_test.go @@ -82,6 +82,23 @@ func TestAccAWSRoute53Record_txtSupport(t *testing.T) { }) } +func TestAccAWSRoute53Record_spfSupport(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckRoute53RecordDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccRoute53RecordConfigSPF, + Check: resource.ComposeTestCheckFunc( + testAccCheckRoute53RecordExists("aws_route53_record.default"), + resource.TestCheckResourceAttr( + "aws_route53_record.default", "records.2930149397", "include:notexample.com"), + ), + }, + }, + }) +} func TestAccAWSRoute53Record_generatesSuffix(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -400,6 +417,19 @@ resource "aws_route53_record" "default" { records = ["lalalala"] } ` +const testAccRoute53RecordConfigSPF = ` +resource "aws_route53_zone" "main" { + name = "notexample.com" +} + +resource "aws_route53_record" "default" { + zone_id = "${aws_route53_zone.main.zone_id}" + name = "test" + type = "SPF" + ttl = "30" + records = ["include:notexample.com"] +} +` const testAccRoute53FailoverCNAMERecord = ` resource "aws_route53_zone" "main" { diff --git a/builtin/providers/aws/structure.go b/builtin/providers/aws/structure.go index dfaf5da2e..b5ca83a79 100644 --- a/builtin/providers/aws/structure.go +++ b/builtin/providers/aws/structure.go @@ -500,7 +500,7 @@ func expandResourceRecords(recs []interface{}, typeStr string) []*route53.Resour for _, r := range recs { s := r.(string) switch typeStr { - case "TXT": + case "TXT", "SPF": str := fmt.Sprintf("\"%s\"", s) records = append(records, &route53.ResourceRecord{Value: aws.String(str)}) default: