From c1bb852390869c3626b87cc8bb6913ff02bc9139 Mon Sep 17 00:00:00 2001 From: AJ Bahnken Date: Thu, 29 Oct 2015 10:27:50 -0700 Subject: [PATCH 1/2] Added measure_latency option to Route 53 Health Check resource. Related to #3273 --- .../providers/aws/resource_aws_route53_health_check.go | 10 ++++++++++ .../aws/resource_aws_route53_health_check_test.go | 1 + 2 files changed, 11 insertions(+) diff --git a/builtin/providers/aws/resource_aws_route53_health_check.go b/builtin/providers/aws/resource_aws_route53_health_check.go index 1850401d9176..16ad47c810e8 100644 --- a/builtin/providers/aws/resource_aws_route53_health_check.go +++ b/builtin/providers/aws/resource_aws_route53_health_check.go @@ -55,6 +55,11 @@ func resourceAwsRoute53HealthCheck() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "measure_latency": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: false, + }, "tags": tagsSchema(), }, } @@ -128,6 +133,10 @@ func resourceAwsRoute53HealthCheckCreate(d *schema.ResourceData, meta interface{ healthConfig.ResourcePath = aws.String(v.(string)) } + if v, ok := d.GetOk("measure_latency"); ok { + healthConfig.MeasureLatency = aws.Bool(v.(bool)) + } + input := &route53.CreateHealthCheckInput{ CallerReference: aws.String(time.Now().Format(time.RFC3339Nano)), HealthCheckConfig: healthConfig, @@ -174,6 +183,7 @@ func resourceAwsRoute53HealthCheckRead(d *schema.ResourceData, meta interface{}) d.Set("ip_address", updated.IPAddress) d.Set("port", updated.Port) d.Set("resource_path", updated.ResourcePath) + d.Set("measure_latency", updated.MeasureLatency) // read the tags req := &route53.ListTagsForResourceInput{ diff --git a/builtin/providers/aws/resource_aws_route53_health_check_test.go b/builtin/providers/aws/resource_aws_route53_health_check_test.go index 9b1441963725..0886b7ba3c05 100644 --- a/builtin/providers/aws/resource_aws_route53_health_check_test.go +++ b/builtin/providers/aws/resource_aws_route53_health_check_test.go @@ -124,6 +124,7 @@ resource "aws_route53_health_check" "foo" { resource_path = "/" failure_threshold = "2" request_interval = "30" + measure_latency = true tags = { Name = "tf-test-health-check" From ab273bb2ee0cb8655d9f78c7d3903b1615fa2b7f Mon Sep 17 00:00:00 2001 From: AJ Bahnken Date: Thu, 29 Oct 2015 12:50:02 -0700 Subject: [PATCH 2/2] Fixed up measure_latency option in r53 health checks. * Added ignoring of param when Type is CALCULATED * Added ForceNew param to measure_latency item in schema * Added check to test --- builtin/providers/aws/resource_aws_route53_health_check.go | 7 +++++-- .../aws/resource_aws_route53_health_check_test.go | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/resource_aws_route53_health_check.go b/builtin/providers/aws/resource_aws_route53_health_check.go index 16ad47c810e8..3f4a2ae6f2f2 100644 --- a/builtin/providers/aws/resource_aws_route53_health_check.go +++ b/builtin/providers/aws/resource_aws_route53_health_check.go @@ -59,6 +59,7 @@ func resourceAwsRoute53HealthCheck() *schema.Resource { Type: schema.TypeBool, Optional: true, Default: false, + ForceNew: true, }, "tags": tagsSchema(), }, @@ -133,8 +134,10 @@ func resourceAwsRoute53HealthCheckCreate(d *schema.ResourceData, meta interface{ healthConfig.ResourcePath = aws.String(v.(string)) } - if v, ok := d.GetOk("measure_latency"); ok { - healthConfig.MeasureLatency = aws.Bool(v.(bool)) + if *healthConfig.Type != route53.HealthCheckTypeCalculated { + if v, ok := d.GetOk("measure_latency"); ok { + healthConfig.MeasureLatency = aws.Bool(v.(bool)) + } } input := &route53.CreateHealthCheckInput{ diff --git a/builtin/providers/aws/resource_aws_route53_health_check_test.go b/builtin/providers/aws/resource_aws_route53_health_check_test.go index 0886b7ba3c05..f6f837c926e8 100644 --- a/builtin/providers/aws/resource_aws_route53_health_check_test.go +++ b/builtin/providers/aws/resource_aws_route53_health_check_test.go @@ -20,6 +20,8 @@ func TestAccAWSRoute53HealthCheck_basic(t *testing.T) { Config: testAccRoute53HealthCheckConfig, Check: resource.ComposeTestCheckFunc( testAccCheckRoute53HealthCheckExists("aws_route53_health_check.foo"), + resource.TestCheckResourceAttr( + "aws_route53_health_check.foo", "measure_latency", "true"), ), }, resource.TestStep{