@ -37,10 +37,13 @@ func resourceAwsElb() *schema.Resource {
} ,
"availability_zones" : & schema . Schema {
Type : schema . Type Lis t,
Type : schema . Type Se t,
Elem : & schema . Schema { Type : schema . TypeString } ,
Optional : true ,
ForceNew : true ,
Set : func ( v interface { } ) int {
return hashcode . String ( v . ( string ) )
} ,
} ,
"instances" : & schema . Schema {
@ -172,7 +175,7 @@ func resourceAwsElbCreate(d *schema.ResourceData, meta interface{}) error {
}
if v , ok := d . GetOk ( "availability_zones" ) ; ok {
elbOpts . AvailZone = expandStringList ( v . ( [ ] interface { } ) )
elbOpts . AvailZone = expandStringList ( v . ( * schema . Set ) . List ( ) )
}
if v , ok := d . GetOk ( "security_groups" ) ; ok {
@ -223,8 +226,7 @@ func resourceAwsElbCreate(d *schema.ResourceData, meta interface{}) error {
}
}
}
return resourceAwsElbUpdate ( d , meta )
}
@ -255,6 +257,7 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error {
d . Set ( "name" , lb . LoadBalancerName )
d . Set ( "dns_name" , lb . DNSName )
d . Set ( "internal" , lb . Scheme == "internal" )
d . Set ( "availability_zones" , flattenAvailabilityZones ( lb . AvailabilityZones ) )
d . Set ( "instances" , flattenInstances ( lb . Instances ) )
d . Set ( "listener" , flattenListeners ( lb . Listeners ) )
d . Set ( "security_groups" , lb . SecurityGroups )
@ -306,25 +309,25 @@ 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" )
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 )