From 40a16449278ee8289acf91ff7c5854e45f5ce509 Mon Sep 17 00:00:00 2001 From: Glen Thomas Date: Tue, 11 Jun 2019 14:35:33 +0100 Subject: [PATCH 1/4] Added Disabled to Route 53 health check resource --- aws/resource_aws_route53_health_check.go | 15 +++++++++++++++ aws/resource_aws_route53_health_check_test.go | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/aws/resource_aws_route53_health_check.go b/aws/resource_aws_route53_health_check.go index 77b527c6acd..1386bd81c1e 100644 --- a/aws/resource_aws_route53_health_check.go +++ b/aws/resource_aws_route53_health_check.go @@ -131,6 +131,12 @@ func resourceAwsRoute53HealthCheck() *schema.Resource { Set: schema.HashString, }, + "disabled": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "tags": tagsSchema(), }, } @@ -196,6 +202,10 @@ func resourceAwsRoute53HealthCheckUpdate(d *schema.ResourceData, meta interface{ updateHealthCheck.Regions = expandStringList(d.Get("regions").(*schema.Set).List()) } + if d.HasChange("disabled") { + updateHealthCheck.Disabled = aws.Bool(d.Get("disabled").(bool)) + } + _, err := conn.UpdateHealthCheck(updateHealthCheck) if err != nil { return err @@ -294,6 +304,10 @@ func resourceAwsRoute53HealthCheckCreate(d *schema.ResourceData, meta interface{ callerRef = fmt.Sprintf("%s-%s", v.(string), callerRef) } + if v, ok := d.GetOk("disabled"); ok { + healthConfig.Disabled = aws.Bool(v.(bool)) + } + input := &route53.CreateHealthCheckInput{ CallerReference: aws.String(callerRef), HealthCheckConfig: healthConfig, @@ -342,6 +356,7 @@ func resourceAwsRoute53HealthCheckRead(d *schema.ResourceData, meta interface{}) d.Set("resource_path", updated.ResourcePath) d.Set("measure_latency", updated.MeasureLatency) d.Set("invert_healthcheck", updated.Inverted) + d.Set("disabled", updated.Disabled) if err := d.Set("child_healthchecks", flattenStringList(updated.ChildHealthChecks)); err != nil { return fmt.Errorf("error setting child_healthchecks: %s", err) diff --git a/aws/resource_aws_route53_health_check_test.go b/aws/resource_aws_route53_health_check_test.go index 61b30cc91d7..f1eb9a83670 100644 --- a/aws/resource_aws_route53_health_check_test.go +++ b/aws/resource_aws_route53_health_check_test.go @@ -279,6 +279,7 @@ resource "aws_route53_health_check" "foo" { request_interval = "30" measure_latency = true invert_healthcheck = true + disabled = false tags = { Name = "tf-test-health-check" @@ -296,6 +297,7 @@ resource "aws_route53_health_check" "foo" { request_interval = "30" measure_latency = true invert_healthcheck = false + disabled = false tags = { Name = "tf-test-health-check" @@ -387,6 +389,7 @@ resource "aws_route53_health_check" "foo" { request_interval = "30" measure_latency = true invert_healthcheck = false + disabled = false search_string = "OK" tags = { @@ -405,6 +408,7 @@ resource "aws_route53_health_check" "foo" { request_interval = "30" measure_latency = true invert_healthcheck = true + disabled = false search_string = "FAILED" tags = { @@ -423,6 +427,7 @@ resource "aws_route53_health_check" "foo" { request_interval = "30" measure_latency = true invert_healthcheck = true + disabled = false tags = { Name = "tf-test-health-check" @@ -441,6 +446,7 @@ resource "aws_route53_health_check" "foo" { measure_latency = true invert_healthcheck = true enable_sni = true + disabled = false tags = { Name = "tf-test-health-check" @@ -459,6 +465,7 @@ resource "aws_route53_health_check" "foo" { measure_latency = true invert_healthcheck = true enable_sni = false + disabled = false tags = { Name = "tf-test-health-check" From 343a4aed12787b81174eabf1c4606af745a12c62 Mon Sep 17 00:00:00 2001 From: Glen Thomas Date: Fri, 6 Dec 2019 11:26:43 +0000 Subject: [PATCH 2/4] Updated website docs --- website/docs/r/route53_health_check.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/r/route53_health_check.html.markdown b/website/docs/r/route53_health_check.html.markdown index e583856c7c8..402f21adece 100644 --- a/website/docs/r/route53_health_check.html.markdown +++ b/website/docs/r/route53_health_check.html.markdown @@ -95,6 +95,7 @@ The following arguments are supported: * `search_string` - (Optional) String searched in the first 5120 bytes of the response body for check to be considered healthy. Only valid with `HTTP_STR_MATCH` and `HTTPS_STR_MATCH`. * `measure_latency` - (Optional) A Boolean value that indicates whether you want Route 53 to measure the latency between health checkers in multiple AWS regions and your endpoint and to display CloudWatch latency graphs in the Route 53 console. * `invert_healthcheck` - (Optional) A boolean value that indicates whether the status of health check should be inverted. For example, if a health check is healthy but Inverted is True , then Route 53 considers the health check to be unhealthy. +* `disable` - (Optional) A boolean value that stops Route 53 from performing health checks. When true Route 53 stops submitting requests to your application, server, or other resource, stops aggregating the status of the referenced health checks and stops monitoring the corresponding CloudWatch metrics. After you disable a health check, Route 53 considers the status of the health check to always be healthy. If you configured DNS failover, Route 53 continues to route traffic to the corresponding resources. If you want to stop routing traffic to a resource, change the value of `invert_healthcheck`. * `enable_sni` - (Optional) A boolean value that indicates whether Route53 should send the `fqdn` to the endpoint when performing the health check. This defaults to AWS' defaults: when the `type` is "HTTPS" `enable_sni` defaults to `true`, when `type` is anything else `enable_sni` defaults to `false`. * `child_healthchecks` - (Optional) For a specified parent health check, a list of HealthCheckId values for the associated child health checks. * `child_health_threshold` - (Optional) The minimum number of child health checks that must be healthy for Route 53 to consider the parent health check to be healthy. Valid values are integers between 0 and 256, inclusive From e2075b58b53e1278fa799a2b25bb18b290429fd9 Mon Sep 17 00:00:00 2001 From: Glen Thomas Date: Fri, 6 Dec 2019 11:26:43 +0000 Subject: [PATCH 3/4] Updated website docs From 1d0e7f874de42d48d30e2ebe8b9101bc1365cab3 Mon Sep 17 00:00:00 2001 From: Angie Pinilla Date: Wed, 12 Aug 2020 20:20:34 -0400 Subject: [PATCH 4/4] add formatted documentation and new test --- aws/resource_aws_route53_health_check_test.go | 53 +++++++++++++++++++ .../docs/r/route53_health_check.html.markdown | 11 ++-- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_route53_health_check_test.go b/aws/resource_aws_route53_health_check_test.go index 578505ac492..ad9aa7a4507 100644 --- a/aws/resource_aws_route53_health_check_test.go +++ b/aws/resource_aws_route53_health_check_test.go @@ -285,6 +285,45 @@ func TestAccAWSRoute53HealthCheck_withSNI(t *testing.T) { }) } +func TestAccAWSRoute53HealthCheck_Disabled(t *testing.T) { + var check route53.HealthCheck + resourceName := "aws_route53_health_check.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckRoute53HealthCheckDestroy, + Steps: []resource.TestStep{ + { + Config: testAccRoute53HealthCheckConfigDisabled(true), + Check: resource.ComposeTestCheckFunc( + testAccCheckRoute53HealthCheckExists(resourceName, &check), + resource.TestCheckResourceAttr(resourceName, "disabled", "true"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccRoute53HealthCheckConfigDisabled(false), + Check: resource.ComposeTestCheckFunc( + testAccCheckRoute53HealthCheckExists(resourceName, &check), + resource.TestCheckResourceAttr(resourceName, "disabled", "false"), + ), + }, + { + Config: testAccRoute53HealthCheckConfigDisabled(true), + Check: resource.ComposeTestCheckFunc( + testAccCheckRoute53HealthCheckExists(resourceName, &check), + resource.TestCheckResourceAttr(resourceName, "disabled", "true"), + ), + }, + }, + }) +} + func TestAccAWSRoute53HealthCheck_disappears(t *testing.T) { var check route53.HealthCheck resourceName := "aws_route53_health_check.test" @@ -636,3 +675,17 @@ resource "aws_route53_health_check" "test" { } } ` + +func testAccRoute53HealthCheckConfigDisabled(disabled bool) string { + return fmt.Sprintf(` +resource "aws_route53_health_check" "test" { + disabled = %[1]t + failure_threshold = "2" + fqdn = "dev.notexample.com" + port = 80 + request_interval = "30" + resource_path = "/" + type = "HTTP" +} +`, disabled) +} diff --git a/website/docs/r/route53_health_check.html.markdown b/website/docs/r/route53_health_check.html.markdown index ef875a75d72..8475b866ebc 100644 --- a/website/docs/r/route53_health_check.html.markdown +++ b/website/docs/r/route53_health_check.html.markdown @@ -83,6 +83,8 @@ resource "aws_route53_health_check" "foo" { The following arguments are supported: +~> **Note:** At least one of either `fqdn` or `ip_address` must be specified. + * `reference_name` - (Optional) This is a reference name used in Caller Reference (helpful for identifying single health_check set amongst others) * `fqdn` - (Optional) The fully qualified domain name of the endpoint to be checked. @@ -95,7 +97,12 @@ The following arguments are supported: * `search_string` - (Optional) String searched in the first 5120 bytes of the response body for check to be considered healthy. Only valid with `HTTP_STR_MATCH` and `HTTPS_STR_MATCH`. * `measure_latency` - (Optional) A Boolean value that indicates whether you want Route 53 to measure the latency between health checkers in multiple AWS regions and your endpoint and to display CloudWatch latency graphs in the Route 53 console. * `invert_healthcheck` - (Optional) A boolean value that indicates whether the status of health check should be inverted. For example, if a health check is healthy but Inverted is True , then Route 53 considers the health check to be unhealthy. -* `disable` - (Optional) A boolean value that stops Route 53 from performing health checks. When true Route 53 stops submitting requests to your application, server, or other resource, stops aggregating the status of the referenced health checks and stops monitoring the corresponding CloudWatch metrics. After you disable a health check, Route 53 considers the status of the health check to always be healthy. If you configured DNS failover, Route 53 continues to route traffic to the corresponding resources. If you want to stop routing traffic to a resource, change the value of `invert_healthcheck`. +* `disabled` - (Optional) A boolean value that stops Route 53 from performing health checks. When set to true, Route 53 will do the following depending on the type of health check: + * For health checks that check the health of endpoints, Route5 53 stops submitting requests to your application, server, or other resource. + * For calculated health checks, Route 53 stops aggregating the status of the referenced health checks. + * For health checks that monitor CloudWatch alarms, Route 53 stops monitoring the corresponding CloudWatch metrics. + + ~> **Note:** After you disable a health check, Route 53 considers the status of the health check to always be healthy. If you configured DNS failover, Route 53 continues to route traffic to the corresponding resources. If you want to stop routing traffic to a resource, change the value of `invert_healthcheck`. * `enable_sni` - (Optional) A boolean value that indicates whether Route53 should send the `fqdn` to the endpoint when performing the health check. This defaults to AWS' defaults: when the `type` is "HTTPS" `enable_sni` defaults to `true`, when `type` is anything else `enable_sni` defaults to `false`. * `child_healthchecks` - (Optional) For a specified parent health check, a list of HealthCheckId values for the associated child health checks. * `child_health_threshold` - (Optional) The minimum number of child health checks that must be healthy for Route 53 to consider the parent health check to be healthy. Valid values are integers between 0 and 256, inclusive @@ -106,8 +113,6 @@ The following arguments are supported: * `tags` - (Optional) A map of tags to assign to the health check. -At least one of either `fqdn` or `ip_address` must be specified. - ## Attributes Reference The following attributes are exported in addition to the arguments listed above: