Skip to content

Commit

Permalink
Merge pull request #20731 from ankita10051991/f-aws_route53_health_ch…
Browse files Browse the repository at this point in the history
…eck_update

Add recovery control health check type
  • Loading branch information
anGie44 committed Aug 31, 2021
2 parents c5a5462 + 9664247 commit 2543ac3
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/20731.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource_aws_route53_health_check: Add `RECOVERY_CONTROL` health check type and `routing_control_arn` argument
```
14 changes: 14 additions & 0 deletions aws/resource_aws_route53_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ func resourceAwsRoute53HealthCheck() *schema.Resource {
Default: false,
},

"routing_control_arn": {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
ValidateFunc: validateArn,
},

"tags": tagsSchema(),
"tags_all": tagsSchemaComputed(),
},
Expand Down Expand Up @@ -335,6 +342,12 @@ func resourceAwsRoute53HealthCheckCreate(d *schema.ResourceData, meta interface{
healthConfig.Disabled = aws.Bool(v.(bool))
}

if *healthConfig.Type == route53.HealthCheckTypeRecoveryControl {
if v, ok := d.GetOk("routing_control_arn"); ok {
healthConfig.RoutingControlArn = aws.String(v.(string))
}
}

input := &route53.CreateHealthCheckInput{
CallerReference: aws.String(callerRef),
HealthCheckConfig: healthConfig,
Expand Down Expand Up @@ -386,6 +399,7 @@ func resourceAwsRoute53HealthCheckRead(d *schema.ResourceData, meta interface{})
d.Set("measure_latency", updated.MeasureLatency)
d.Set("invert_healthcheck", updated.Inverted)
d.Set("disabled", updated.Disabled)
d.Set("routing_control_arn", updated.RoutingControlArn)

if err := d.Set("child_healthchecks", flattenStringList(updated.ChildHealthChecks)); err != nil {
return fmt.Errorf("error setting child_healthchecks: %w", err)
Expand Down
43 changes: 43 additions & 0 deletions aws/resource_aws_route53_health_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/aws/aws-sdk-go/aws/endpoints"
"github.com/aws/aws-sdk-go/service/route53"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)
Expand Down Expand Up @@ -333,6 +334,32 @@ func TestAccAWSRoute53HealthCheck_Disabled(t *testing.T) {
})
}

func TestAccAWSRoute53HealthCheck_withRoutingControlArn(t *testing.T) {
var check route53.HealthCheck
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_route53_health_check.test"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ErrorCheck: testAccErrorCheck(t, route53.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckRoute53HealthCheckDestroy,
Steps: []resource.TestStep{
{
Config: testAccRoute53HealthCheckConfigRoutingControlArn(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckRoute53HealthCheckExists(resourceName, &check),
resource.TestCheckResourceAttr(resourceName, "type", "RECOVERY_CONTROL"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAWSRoute53HealthCheck_disappears(t *testing.T) {
var check route53.HealthCheck
resourceName := "aws_route53_health_check.test"
Expand Down Expand Up @@ -690,3 +717,19 @@ resource "aws_route53_health_check" "test" {
}
`, disabled)
}

func testAccRoute53HealthCheckConfigRoutingControlArn(rName string) string {
return fmt.Sprintf(`
resource "aws_route53recoverycontrolconfig_cluster" "test" {
name = %[1]q
}
resource "aws_route53recoverycontrolconfig_routing_control" "test" {
name = %[1]q
cluster_arn = aws_route53recoverycontrolconfig_cluster.test.arn
}
resource "aws_route53_health_check" "test" {
type = "RECOVERY_CONTROL"
routing_control_arn = aws_route53recoverycontrolconfig_routing_control.test.arn
}
`, rName)
}
3 changes: 2 additions & 1 deletion website/docs/r/route53_health_check.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ The following arguments are supported:
* `fqdn` - (Optional) The fully qualified domain name of the endpoint to be checked.
* `ip_address` - (Optional) The IP address of the endpoint to be checked.
* `port` - (Optional) The port of the endpoint to be checked.
* `type` - (Required) The protocol to use when performing health checks. Valid values are `HTTP`, `HTTPS`, `HTTP_STR_MATCH`, `HTTPS_STR_MATCH`, `TCP`, `CALCULATED` and `CLOUDWATCH_METRIC`.
* `type` - (Required) The protocol to use when performing health checks. Valid values are `HTTP`, `HTTPS`, `HTTP_STR_MATCH`, `HTTPS_STR_MATCH`, `TCP`, `CALCULATED`, `CLOUDWATCH_METRIC` and `RECOVERY_CONTROL`.
* `failure_threshold` - (Required) The number of consecutive health checks that an endpoint must pass or fail.
* `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.
Expand All @@ -110,6 +110,7 @@ The following arguments are supported:
* `cloudwatch_alarm_region` - (Optional) The CloudWatchRegion that the CloudWatch alarm was created in.
* `insufficient_data_health_status` - (Optional) The status of the health check when CloudWatch has insufficient data about the state of associated alarm. Valid values are `Healthy` , `Unhealthy` and `LastKnownStatus`.
* `regions` - (Optional) A list of AWS regions that you want Amazon Route 53 health checkers to check the specified endpoint from.
* `routing_control_arn` - (Optional) The Amazon Resource Name (ARN) for the Route 53 Application Recovery Controller routing control. This is used when health check type is `RECOVERY_CONTROL`
* `tags` - (Optional) A map of tags to assign to the health check. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.

## Attributes Reference
Expand Down

0 comments on commit 2543ac3

Please sign in to comment.