diff --git a/builtin/providers/aws/resource_aws_elb.go b/builtin/providers/aws/resource_aws_elb.go index ff9131c94..b54dac60f 100644 --- a/builtin/providers/aws/resource_aws_elb.go +++ b/builtin/providers/aws/resource_aws_elb.go @@ -163,7 +163,7 @@ func resourceAwsElb() *schema.Resource { }, "health_check": &schema.Schema{ - Type: schema.TypeSet, + Type: schema.TypeList, Optional: true, Computed: true, Elem: &schema.Resource{ @@ -194,7 +194,6 @@ func resourceAwsElb() *schema.Resource { }, }, }, - Set: resourceAwsElbHealthCheckHash, }, "dns_name": &schema.Schema{ @@ -374,6 +373,7 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error { et = resp.TagDescriptions[0].Tags } d.Set("tags", tagsToMapELB(et)) + // There's only one health check, so save that to state as we // currently can if *lb.HealthCheck.Target != "" { @@ -574,9 +574,11 @@ func resourceAwsElbUpdate(d *schema.ResourceData, meta interface{}) error { } if d.HasChange("health_check") { - vs := d.Get("health_check").(*schema.Set).List() - if len(vs) > 0 { - check := vs[0].(map[string]interface{}) + hc := d.Get("health_check").([]interface{}) + if len(hc) > 1 { + return fmt.Errorf("Only one health check per ELB is supported") + } else if len(hc) > 0 { + check := hc[0].(map[string]interface{}) configureHealthCheckOpts := elb.ConfigureHealthCheckInput{ LoadBalancerName: aws.String(d.Id()), HealthCheck: &elb.HealthCheck{ @@ -711,18 +713,6 @@ func resourceAwsElbDelete(d *schema.ResourceData, meta interface{}) error { return nil } -func resourceAwsElbHealthCheckHash(v interface{}) int { - var buf bytes.Buffer - m := v.(map[string]interface{}) - buf.WriteString(fmt.Sprintf("%d-", m["healthy_threshold"].(int))) - buf.WriteString(fmt.Sprintf("%d-", m["unhealthy_threshold"].(int))) - buf.WriteString(fmt.Sprintf("%s-", m["target"].(string))) - buf.WriteString(fmt.Sprintf("%d-", m["interval"].(int))) - buf.WriteString(fmt.Sprintf("%d-", m["timeout"].(int))) - - return hashcode.String(buf.String()) -} - func resourceAwsElbAccessLogsHash(v interface{}) int { var buf bytes.Buffer m := v.(map[string]interface{}) diff --git a/builtin/providers/aws/resource_aws_elb_test.go b/builtin/providers/aws/resource_aws_elb_test.go index 2b246dd9e..eae4138dd 100644 --- a/builtin/providers/aws/resource_aws_elb_test.go +++ b/builtin/providers/aws/resource_aws_elb_test.go @@ -339,15 +339,15 @@ func TestAccAWSELB_HealthCheck(t *testing.T) { testAccCheckAWSELBExists("aws_elb.bar", &conf), testAccCheckAWSELBAttributesHealthCheck(&conf), resource.TestCheckResourceAttr( - "aws_elb.bar", "health_check.3484319807.healthy_threshold", "5"), + "aws_elb.bar", "health_check.0.healthy_threshold", "5"), resource.TestCheckResourceAttr( - "aws_elb.bar", "health_check.3484319807.unhealthy_threshold", "5"), + "aws_elb.bar", "health_check.0.unhealthy_threshold", "5"), resource.TestCheckResourceAttr( - "aws_elb.bar", "health_check.3484319807.target", "HTTP:8000/"), + "aws_elb.bar", "health_check.0.target", "HTTP:8000/"), resource.TestCheckResourceAttr( - "aws_elb.bar", "health_check.3484319807.timeout", "30"), + "aws_elb.bar", "health_check.0.timeout", "30"), resource.TestCheckResourceAttr( - "aws_elb.bar", "health_check.3484319807.interval", "60"), + "aws_elb.bar", "health_check.0.interval", "60"), ), }, }, @@ -364,14 +364,14 @@ func TestAccAWSELBUpdate_HealthCheck(t *testing.T) { Config: testAccAWSELBConfigHealthCheck, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( - "aws_elb.bar", "health_check.3484319807.healthy_threshold", "5"), + "aws_elb.bar", "health_check.0.healthy_threshold", "5"), ), }, resource.TestStep{ Config: testAccAWSELBConfigHealthCheck_update, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( - "aws_elb.bar", "health_check.2648756019.healthy_threshold", "10"), + "aws_elb.bar", "health_check.0.healthy_threshold", "10"), ), }, },