Add update support for `search_string`

This commit is contained in:
Alexander Hellbom 2016-10-05 13:23:19 +02:00
parent d4eb64a317
commit f6c66025cc
2 changed files with 71 additions and 0 deletions

View File

@ -151,6 +151,10 @@ func resourceAwsRoute53HealthCheckUpdate(d *schema.ResourceData, meta interface{
updateHealthCheck.HealthThreshold = aws.Int64(int64(d.Get("child_health_threshold").(int))) updateHealthCheck.HealthThreshold = aws.Int64(int64(d.Get("child_health_threshold").(int)))
} }
if d.HasChange("search_string") {
updateHealthCheck.SearchString = aws.String(d.Get("search_string").(string))
}
if d.HasChange("cloudwatch_alarm_name") || d.HasChange("cloudwatch_alarm_region") { if d.HasChange("cloudwatch_alarm_name") || d.HasChange("cloudwatch_alarm_region") {
cloudwatchAlarm := &route53.AlarmIdentifier{ cloudwatchAlarm := &route53.AlarmIdentifier{
Name: aws.String(d.Get("cloudwatch_alarm_name").(string)), Name: aws.String(d.Get("cloudwatch_alarm_name").(string)),

View File

@ -41,6 +41,37 @@ func TestAccAWSRoute53HealthCheck_basic(t *testing.T) {
}) })
} }
func TestAccAWSRoute53HealthCheck_withSearchString(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "aws_route53_health_check.foo",
Providers: testAccProviders,
CheckDestroy: testAccCheckRoute53HealthCheckDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRoute53HealthCheckConfigWithSearchString,
Check: resource.ComposeTestCheckFunc(
testAccCheckRoute53HealthCheckExists("aws_route53_health_check.foo"),
resource.TestCheckResourceAttr(
"aws_route53_health_check.foo", "invert_healthcheck", "false"),
resource.TestCheckResourceAttr(
"aws_route53_health_check.foo", "search_string", "OK"),
),
},
resource.TestStep{
Config: testAccRoute53HealthCheckConfigWithSearchStringUpdate,
Check: resource.ComposeTestCheckFunc(
testAccCheckRoute53HealthCheckExists("aws_route53_health_check.foo"),
resource.TestCheckResourceAttr(
"aws_route53_health_check.foo", "invert_healthcheck", "true"),
resource.TestCheckResourceAttr(
"aws_route53_health_check.foo", "search_string", "FAILED"),
),
},
},
})
}
func TestAccAWSRoute53HealthCheck_withChildHealthChecks(t *testing.T) { func TestAccAWSRoute53HealthCheck_withChildHealthChecks(t *testing.T) {
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
@ -247,3 +278,39 @@ resource "aws_route53_health_check" "foo" {
insufficient_data_health_status = "Healthy" insufficient_data_health_status = "Healthy"
} }
` `
const testAccRoute53HealthCheckConfigWithSearchString = `
resource "aws_route53_health_check" "foo" {
fqdn = "dev.notexample.com"
port = 80
type = "HTTP_STR_MATCH"
resource_path = "/"
failure_threshold = "2"
request_interval = "30"
measure_latency = true
invert_healthcheck = false
search_string = "OK"
tags = {
Name = "tf-test-health-check"
}
}
`
const testAccRoute53HealthCheckConfigWithSearchStringUpdate = `
resource "aws_route53_health_check" "foo" {
fqdn = "dev.notexample.com"
port = 80
type = "HTTP_STR_MATCH"
resource_path = "/"
failure_threshold = "5"
request_interval = "30"
measure_latency = true
invert_healthcheck = true
search_string = "FAILED"
tags = {
Name = "tf-test-health-check"
}
}
`