diff --git a/builtin/providers/aws/resource_aws_elb.go b/builtin/providers/aws/resource_aws_elb.go index 26f9c5ffc..75374137e 100644 --- a/builtin/providers/aws/resource_aws_elb.go +++ b/builtin/providers/aws/resource_aws_elb.go @@ -337,6 +337,7 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error { d.Set("dns_name", lb.DNSName) d.Set("internal", lb.Scheme == "internal") d.Set("instances", flattenInstances(lb.Instances)) + d.Set("listener", flattenListeners(lb.Listeners)) d.Set("security_groups", lb.SecurityGroups) d.Set("subnets", lb.Subnets) diff --git a/builtin/providers/aws/structure.go b/builtin/providers/aws/structure.go index 4617be5d5..699e3ac14 100644 --- a/builtin/providers/aws/structure.go +++ b/builtin/providers/aws/structure.go @@ -176,6 +176,21 @@ func flattenInstances(list []elb.Instance) []string { 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 // and returns a []string func expandStringList(configured []interface{}) []string {