Merge pull request #635 from snehaso/cross_zone_lb

[AWS]  enabled cross zone load balancing
This commit is contained in:
Armon Dadgar 2014-12-10 10:55:54 -08:00
commit 8e32076d55
3 changed files with 29 additions and 2 deletions

View File

@ -31,6 +31,11 @@ func resourceAwsElb() *schema.Resource {
Computed: true, Computed: true,
}, },
"cross_zone_load_balancing": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
},
"availability_zones": &schema.Schema{ "availability_zones": &schema.Schema{
Type: schema.TypeList, Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
@ -218,7 +223,8 @@ func resourceAwsElbCreate(d *schema.ResourceData, meta interface{}) error {
} }
} }
} }
return resourceAwsElbUpdate(d, meta) return resourceAwsElbUpdate(d, meta)
} }
@ -300,10 +306,26 @@ func resourceAwsElbUpdate(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Failure deregistering instances: %s", err) return fmt.Errorf("Failure deregistering instances: %s", err)
} }
} }
d.SetPartial("instances") 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) d.Partial(false)
return resourceAwsElbRead(d, meta) return resourceAwsElbRead(d, meta)
} }

View File

@ -43,6 +43,8 @@ func TestAccAWSELB_basic(t *testing.T) {
"aws_elb.bar", "listener.0.lb_port", "80"), "aws_elb.bar", "listener.0.lb_port", "80"),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"aws_elb.bar", "listener.0.lb_protocol", "http"), "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 = [] instances = []
cross_zone_load_balancing = true
} }
` `

View File

@ -42,6 +42,7 @@ resource "aws_elb" "bar" {
} }
instances = ["${aws_instance.foo.id}"] instances = ["${aws_instance.foo.id}"]
cross_zone_load_balancing = true
} }
``` ```
@ -57,6 +58,7 @@ The following arguments are supported:
* `internal` - (Optional) If true, ELB will be an internal ELB. * `internal` - (Optional) If true, ELB will be an internal ELB.
* `listener` - (Required) A list of listener blocks. Listeners documented below. * `listener` - (Required) A list of listener blocks. Listeners documented below.
* `health_check` - (Optional) A health_check block. Health Check documented below. * `health_check` - (Optional) A health_check block. Health Check documented below.
* `cross_zone_load_balancing` - (Optional) Enable cross-zone load balancing.
Listeners support the following: Listeners support the following: