From 10ca0559aeac11a94bdd8875285fab02bb015cd6 Mon Sep 17 00:00:00 2001 From: Luke Amdor Date: Thu, 12 Nov 2015 14:57:41 -0600 Subject: [PATCH] provider/aws: no weight for all set_identifier --- .../aws/resource_aws_route53_record.go | 5 +- .../aws/resource_aws_route53_record_test.go | 57 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_route53_record.go b/builtin/providers/aws/resource_aws_route53_record.go index 25d73683c..a5b9ef468 100644 --- a/builtin/providers/aws/resource_aws_route53_record.go +++ b/builtin/providers/aws/resource_aws_route53_record.go @@ -417,7 +417,10 @@ func resourceAwsRoute53RecordBuildSet(d *schema.ResourceData, zoneName string) ( if v, ok := d.GetOk("set_identifier"); ok { rec.SetIdentifier = aws.String(v.(string)) - rec.Weight = aws.Int64(int64(d.Get("weight").(int))) + } + + if v, ok := d.GetOk("weight"); ok { + rec.Weight = aws.Int64(int64(v.(int))) } return rec, nil diff --git a/builtin/providers/aws/resource_aws_route53_record_test.go b/builtin/providers/aws/resource_aws_route53_record_test.go index d10653a0c..690e0fe47 100644 --- a/builtin/providers/aws/resource_aws_route53_record_test.go +++ b/builtin/providers/aws/resource_aws_route53_record_test.go @@ -122,6 +122,23 @@ func TestAccAWSRoute53Record_wildcard(t *testing.T) { }) } +func TestAccAWSRoute53Record_failover(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckRoute53RecordDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccRoute53FailoverCNAMERecord, + Check: resource.ComposeTestCheckFunc( + testAccCheckRoute53RecordExists("aws_route53_record.www-primary"), + testAccCheckRoute53RecordExists("aws_route53_record.www-secondary"), + ), + }, + }, + }) +} + func TestAccAWSRoute53Record_weighted(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -384,6 +401,46 @@ resource "aws_route53_record" "default" { } ` +const testAccRoute53FailoverCNAMERecord = ` +resource "aws_route53_zone" "main" { + name = "notexample.com" +} + +resource "aws_route53_health_check" "foo" { + fqdn = "dev.notexample.com" + port = 80 + type = "HTTP" + resource_path = "/" + failure_threshold = "2" + request_interval = "30" + + tags = { + Name = "tf-test-health-check" + } +} + +resource "aws_route53_record" "www-primary" { + zone_id = "${aws_route53_zone.main.zone_id}" + name = "www" + type = "CNAME" + ttl = "5" + failover = "PRIMARY" + health_check_id = "${aws_route53_health_check.foo.id}" + set_identifier = "www-primary" + records = ["primary.notexample.com"] +} + +resource "aws_route53_record" "www-secondary" { + zone_id = "${aws_route53_zone.main.zone_id}" + name = "www" + type = "CNAME" + ttl = "5" + failover = "SECONDARY" + set_identifier = "www-secondary" + records = ["secondary.notexample.com"] +} +` + const testAccRoute53WeightedCNAMERecord = ` resource "aws_route53_zone" "main" { name = "notexample.com"