providers/aws: resource ELB listeners [GH-314]

This commit is contained in:
Mitchell Hashimoto 2014-10-10 16:35:52 -07:00
parent aee9c480b2
commit 51d66b678d
2 changed files with 16 additions and 0 deletions

View File

@ -337,6 +337,7 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error {
d.Set("dns_name", lb.DNSName) d.Set("dns_name", lb.DNSName)
d.Set("internal", lb.Scheme == "internal") d.Set("internal", lb.Scheme == "internal")
d.Set("instances", flattenInstances(lb.Instances)) d.Set("instances", flattenInstances(lb.Instances))
d.Set("listener", flattenListeners(lb.Listeners))
d.Set("security_groups", lb.SecurityGroups) d.Set("security_groups", lb.SecurityGroups)
d.Set("subnets", lb.Subnets) d.Set("subnets", lb.Subnets)

View File

@ -176,6 +176,21 @@ func flattenInstances(list []elb.Instance) []string {
return result 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))
for _, i := range list {
result = append(result, map[string]interface{}{
"instance_port": i.InstancePort,
"instance_protocol": i.InstanceProtocol,
"ssl_certificate_id": i.SSLCertificateId,
"lb_port": i.LoadBalancerPort,
"lb_protocol": i.Protocol,
})
}
return result
}
// Takes the result of flatmap.Expand for an array of strings // Takes the result of flatmap.Expand for an array of strings
// and returns a []string // and returns a []string
func expandStringList(configured []interface{}) []string { func expandStringList(configured []interface{}) []string {