Merge pull request #680 from svanharmelen/f-provider/aws-update-aws-elb-resource
provider/aws: updating the resource to use a set instead of a list
This commit is contained in:
commit
462cc24ce6
|
@ -37,10 +37,13 @@ func resourceAwsElb() *schema.Resource {
|
|||
},
|
||||
|
||||
"availability_zones": &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Type: schema.TypeSet,
|
||||
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 {
|
||||
|
@ -224,7 +227,6 @@ 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)
|
||||
|
|
|
@ -172,6 +172,15 @@ func flattenInstances(list []elb.Instance) []string {
|
|||
return result
|
||||
}
|
||||
|
||||
// Flattens an array of AvailabilityZones into a []string
|
||||
func flattenAvailabilityZones(list []elb.AvailabilityZone) []string {
|
||||
result := make([]string, 0, len(list))
|
||||
for _, z := range list {
|
||||
result = append(result, z.AvailabilityZone)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Flattens an array of Listeners into a []map[string]interface{}
|
||||
func flattenListeners(list []elb.Listener) []map[string]interface{} {
|
||||
result := make([]map[string]interface{}, 0, len(list))
|
||||
|
|
Loading…
Reference in New Issue