providers/aws: make health checks work

This commit is contained in:
Mitchell Hashimoto 2014-10-10 00:07:08 -07:00
parent 12ff354749
commit dd2b1fe442
1 changed files with 20 additions and 30 deletions

View File

@ -215,36 +215,28 @@ func resourceAwsElbCreate(d *schema.ResourceData, meta interface{}) error {
d.SetPartial("security_groups") d.SetPartial("security_groups")
d.SetPartial("subnets") d.SetPartial("subnets")
/* if d.HasChange("health_check") {
if _, ok := rs.Attributes["health_check.#"]; ok { vs := d.Get("health_check").(*schema.Set).List()
v := flatmap.Expand(rs.Attributes, "health_check").([]interface{}) if len(vs) > 0 {
health_check := v[0].(map[string]interface{}) check := vs[0].(map[string]interface{})
healthyThreshold, err := strconv.ParseInt(health_check["healthy_threshold"].(string), 0, 0)
unhealthyThreshold, err := strconv.ParseInt(health_check["unhealthy_threshold"].(string), 0, 0)
interval, err := strconv.ParseInt(health_check["interval"].(string), 0, 0)
timeout, err := strconv.ParseInt(health_check["timeout"].(string), 0, 0)
if err != nil { configureHealthCheckOpts := elb.ConfigureHealthCheck{
return nil, err 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)),
},
}
configureHealthCheckOpts := elb.ConfigureHealthCheck{ _, err = elbconn.ConfigureHealthCheck(&configureHealthCheckOpts)
LoadBalancerName: elbName, if err != nil {
Check: elb.HealthCheck{ return fmt.Errorf("Failure configuring health check: %s", err)
HealthyThreshold: healthyThreshold, }
UnhealthyThreshold: unhealthyThreshold,
Interval: interval,
Target: health_check["target"].(string),
Timeout: timeout,
},
}
_, err = elbconn.ConfigureHealthCheck(&configureHealthCheckOpts)
if err != nil {
return rs, fmt.Errorf("Failure configuring health check: %s", err)
} }
} }
*/
return resourceAwsElbUpdate(d, meta) return resourceAwsElbUpdate(d, meta)
} }
@ -338,13 +330,11 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error {
d.Set("security_groups", lb.SecurityGroups) d.Set("security_groups", lb.SecurityGroups)
d.Set("subnets", lb.Subnets) d.Set("subnets", lb.Subnets)
/*
// There's only one health check, so save that to state as we // There's only one health check, so save that to state as we
// currently can // currently can
if balancer.HealthCheck.Target != "" { if lb.HealthCheck.Target != "" {
toFlatten["health_check"] = flattenHealthCheck(balancer.HealthCheck) d.Set("health_check", flattenHealthCheck(lb.HealthCheck))
} }
*/
return nil return nil
} }