Merge pull request #3900 from Banno/fix-aws-route53-record-failover-weight
provider/aws: fix for creating failover route53 records
This commit is contained in:
commit
839fc5bfee
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue