mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-26 00:16:25 -06:00
Adding support to Route53 HealthCheck for measure_latency and inverting healthcheck
This commit is contained in:
parent
1dd1efa05b
commit
172faca052
@ -47,10 +47,16 @@ func resourceAwsRoute53HealthCheck() *schema.Resource {
|
||||
Optional: true,
|
||||
},
|
||||
|
||||
"invert_healthcheck": &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
},
|
||||
|
||||
"resource_path": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
|
||||
"search_string": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
@ -61,6 +67,7 @@ func resourceAwsRoute53HealthCheck() *schema.Resource {
|
||||
Default: false,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"tags": tagsSchema(),
|
||||
},
|
||||
}
|
||||
@ -89,8 +96,8 @@ func resourceAwsRoute53HealthCheckUpdate(d *schema.ResourceData, meta interface{
|
||||
updateHealthCheck.ResourcePath = aws.String(d.Get("resource_path").(string))
|
||||
}
|
||||
|
||||
if d.HasChange("search_string") {
|
||||
updateHealthCheck.SearchString = aws.String(d.Get("search_string").(string))
|
||||
if d.HasChange("invert_healthcheck") {
|
||||
updateHealthCheck.Inverted = aws.Bool(d.Get("invert_healthcheck").(bool))
|
||||
}
|
||||
|
||||
_, err := conn.UpdateHealthCheck(updateHealthCheck)
|
||||
@ -140,6 +147,20 @@ func resourceAwsRoute53HealthCheckCreate(d *schema.ResourceData, meta interface{
|
||||
}
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("invert_healthcheck"); ok {
|
||||
healthConfig.Inverted = aws.Bool(v.(bool))
|
||||
}
|
||||
|
||||
if *healthConfig.Type == route53.HealthCheckTypeCalculated {
|
||||
if v, ok := d.GetOk("child_healthchecks"); ok {
|
||||
healthConfig.ChildHealthChecks = expandStringList(v.(*schema.Set).List())
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("child_health_threshold"); ok {
|
||||
healthConfig.HealthThreshold = aws.Int64(int64(v.(int)))
|
||||
}
|
||||
}
|
||||
|
||||
input := &route53.CreateHealthCheckInput{
|
||||
CallerReference: aws.String(time.Now().Format(time.RFC3339Nano)),
|
||||
HealthCheckConfig: healthConfig,
|
||||
@ -187,6 +208,7 @@ func resourceAwsRoute53HealthCheckRead(d *schema.ResourceData, meta interface{})
|
||||
d.Set("port", updated.Port)
|
||||
d.Set("resource_path", updated.ResourcePath)
|
||||
d.Set("measure_latency", updated.MeasureLatency)
|
||||
d.Set("invent_healthcheck", updated.Inverted)
|
||||
|
||||
// read the tags
|
||||
req := &route53.ListTagsForResourceInput{
|
||||
@ -222,3 +244,12 @@ func resourceAwsRoute53HealthCheckDelete(d *schema.ResourceData, meta interface{
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func createChildHealthCheckList(s *schema.Set) (nl []*string) {
|
||||
l := s.List()
|
||||
for _, n := range l {
|
||||
nl = append(nl, aws.String(n.(string)))
|
||||
}
|
||||
|
||||
return nl
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ func TestAccAWSRoute53HealthCheck_basic(t *testing.T) {
|
||||
testAccCheckRoute53HealthCheckExists("aws_route53_health_check.foo"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_route53_health_check.foo", "measure_latency", "true"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_route53_health_check.foo", "invert_healthcheck", "true"),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
@ -30,6 +32,8 @@ func TestAccAWSRoute53HealthCheck_basic(t *testing.T) {
|
||||
testAccCheckRoute53HealthCheckExists("aws_route53_health_check.foo"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_route53_health_check.foo", "failure_threshold", "5"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_route53_health_check.foo", "invert_healthcheck", "false"),
|
||||
),
|
||||
},
|
||||
},
|
||||
@ -127,6 +131,7 @@ resource "aws_route53_health_check" "foo" {
|
||||
failure_threshold = "2"
|
||||
request_interval = "30"
|
||||
measure_latency = true
|
||||
invert_healthcheck = true
|
||||
|
||||
tags = {
|
||||
Name = "tf-test-health-check"
|
||||
@ -142,6 +147,8 @@ resource "aws_route53_health_check" "foo" {
|
||||
resource_path = "/"
|
||||
failure_threshold = "5"
|
||||
request_interval = "30"
|
||||
measure_latency = true
|
||||
invert_healthcheck = false
|
||||
|
||||
tags = {
|
||||
Name = "tf-test-health-check"
|
||||
|
@ -36,6 +36,8 @@ The following arguments are supported:
|
||||
* `request_interval` - (Required) The number of seconds between the time that Amazon Route 53 gets a response from your endpoint and the time that it sends the next health-check request.
|
||||
* `resource_path` - (Optional) The path that you want Amazon Route 53 to request when performing health checks.
|
||||
* `search_string` - (Optional) String searched in respoonse body for check to considered healthy.
|
||||
* `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.
|
||||
* `tags` - (Optional) A mapping of tags to assign to the health check.
|
||||
|
||||
At least one of either `fqdn` or `ip_address` must be specified.
|
||||
|
Loading…
Reference in New Issue
Block a user