provider/aws: fix for #915 - aws_elb.health_check attributes does not update during update

This commit is contained in:
Greg Osuri 2015-02-02 19:25:54 -08:00
parent c18b01fa2a
commit 04ac1ffd02
2 changed files with 69 additions and 0 deletions

View File

@ -331,6 +331,28 @@ func resourceAwsElbUpdate(d *schema.ResourceData, meta interface{}) error {
d.SetPartial("cross_zone_load_balancing")
}
if d.HasChange("health_check") {
vs := d.Get("health_check").(*schema.Set).List()
if len(vs) > 0 {
check := vs[0].(map[string]interface{})
configureHealthCheckOpts := elb.ConfigureHealthCheck{
LoadBalancerName: d.Id(),
Check: elb.HealthCheck{
HealthyThreshold: int64(check["healthy_threshold"].(int)),
UnhealthyThreshold: int64(check["unhealthy_threshold"].(int)),
Interval: int64(check["interval"].(int)),
Target: check["target"].(string),
Timeout: int64(check["timeout"].(int)),
},
}
_, err := elbconn.ConfigureHealthCheck(&configureHealthCheckOpts)
if err != nil {
return fmt.Errorf("Failure configuring health check: %s", err)
}
d.SetPartial("health_check")
}
}
d.Partial(false)
return resourceAwsElbRead(d, meta)
}

View File

@ -152,6 +152,31 @@ func TestAccAWSELB_HealthCheck(t *testing.T) {
},
})
}
func TestAccAWSELBUpdate_HealthCheck(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSELBDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSELBConfigHealthCheck,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"aws_elb.bar", "health_check.3484319807.healthy_threshold", "5"),
),
},
resource.TestStep{
Config: testAccAWSELBConfigHealthCheck_update,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"aws_elb.bar", "health_check.2648756019.healthy_threshold", "10"),
),
},
},
})
}
func testAccCheckAWSELBDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).elbconn
@ -418,3 +443,25 @@ resource "aws_elb" "bar" {
}
}
`
const testAccAWSELBConfigHealthCheck_update = `
resource "aws_elb" "bar" {
name = "foobar-terraform-test"
availability_zones = ["us-west-2a"]
listener {
instance_port = 8000
instance_protocol = "http"
lb_port = 80
lb_protocol = "http"
}
health_check {
healthy_threshold = 10
unhealthy_threshold = 5
target = "HTTP:8000/"
interval = 60
timeout = 30
}
}
`