From 1d3e30b353a544a2e59dc8ce6b097c7218c4ae17 Mon Sep 17 00:00:00 2001 From: Sneha Somwanshi Date: Wed, 10 Dec 2014 11:37:08 +0530 Subject: [PATCH] enabled cross zone load balancing --- builtin/providers/aws/resource_aws_elb.go | 26 +++++++++++++++++-- .../providers/aws/resource_aws_elb_test.go | 3 +++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/resource_aws_elb.go b/builtin/providers/aws/resource_aws_elb.go index c08b3d6da..eb05143ab 100644 --- a/builtin/providers/aws/resource_aws_elb.go +++ b/builtin/providers/aws/resource_aws_elb.go @@ -31,6 +31,11 @@ func resourceAwsElb() *schema.Resource { Computed: true, }, + "cross_zone_load_balancing": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + }, + "availability_zones": &schema.Schema{ Type: schema.TypeList, Elem: &schema.Schema{Type: schema.TypeString}, @@ -218,7 +223,8 @@ func resourceAwsElbCreate(d *schema.ResourceData, meta interface{}) error { } } } - + + return resourceAwsElbUpdate(d, meta) } @@ -300,10 +306,26 @@ func resourceAwsElbUpdate(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Failure deregistering instances: %s", err) } } - + d.SetPartial("instances") } + log.Println("[INFO] outside modify attributes") + if d.HasChange("cross_zone_load_balancing") { + log.Println("[INFO] inside modify attributes") + attrs := elb.ModifyLoadBalancerAttributes{ + LoadBalancerName: d.Get("name").(string), + LoadBalancerAttributes: elb.LoadBalancerAttributes{ + CrossZoneLoadBalancingEnabled: d.Get("cross_zone_load_balancing").(bool), + }, + } + _, err := elbconn.ModifyLoadBalancerAttributes(&attrs) + if err != nil { + return fmt.Errorf("Failure configuring health check: %s", err) + } + d.SetPartial("cross_zone_load_balancing") + } + d.Partial(false) return resourceAwsElbRead(d, meta) } diff --git a/builtin/providers/aws/resource_aws_elb_test.go b/builtin/providers/aws/resource_aws_elb_test.go index 05078b673..ec78b22e8 100644 --- a/builtin/providers/aws/resource_aws_elb_test.go +++ b/builtin/providers/aws/resource_aws_elb_test.go @@ -43,6 +43,8 @@ func TestAccAWSELB_basic(t *testing.T) { "aws_elb.bar", "listener.0.lb_port", "80"), resource.TestCheckResourceAttr( "aws_elb.bar", "listener.0.lb_protocol", "http"), + resource.TestCheckResourceAttr( + "aws_elb.bar", "cross_zone_load_balancing", "true"), ), }, }, @@ -256,6 +258,7 @@ resource "aws_elb" "bar" { } instances = [] + cross_zone_load_balancing = true } `