diff --git a/builtin/providers/aws/resource_aws_elb.go b/builtin/providers/aws/resource_aws_elb.go index 620ae5ee0..8d64e0588 100644 --- a/builtin/providers/aws/resource_aws_elb.go +++ b/builtin/providers/aws/resource_aws_elb.go @@ -330,13 +330,13 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error { d.Set("source_security_group", lb.SourceSecurityGroup.GroupName) } d.Set("subnets", lb.Subnets) - d.Set("idle_timeout", lbAttrs.ConnectionSettings.IdleTimeout) - d.Set("connection_draining", lbAttrs.ConnectionDraining.Enabled) - d.Set("connection_draining_timeout", lbAttrs.ConnectionDraining.Timeout) - d.Set("access_logs", lbAttrs.AccessLog) + d.Set("idle_timeout", lbAttrs.ConnectionSettings.IdleTimeout) + d.Set("connection_draining", lbAttrs.ConnectionDraining.Enabled) + d.Set("connection_draining_timeout", lbAttrs.ConnectionDraining.Timeout) + d.Set("access_logs", flattenAccessLog(lbAttrs.AccessLog)) - resp, err := elbconn.DescribeTags(&elb.DescribeTagsInput{ - LoadBalancerNames: []*string{lb.LoadBalancerName}, + resp, err := elbconn.DescribeTags(&elb.DescribeTagsInput{ + LoadBalancerNames: []*string{lb.LoadBalancerName}, }) var et []*elb.Tag diff --git a/builtin/providers/aws/structure.go b/builtin/providers/aws/structure.go index fd581c84a..e7590001f 100644 --- a/builtin/providers/aws/structure.go +++ b/builtin/providers/aws/structure.go @@ -234,6 +234,22 @@ func expandElastiCacheParameters(configured []interface{}) ([]*elasticache.Param return parameters, nil } +// Flattens an access log into something that flatmap.Flatten() can handle +func flattenAccessLog(log *elb.AccessLog) []map[string]interface{} { + result := make([]map[string]interface{}, 0, 1) + + if log != nil { + result = append(result, map[string]interface{}{ + "enabled": *log.Enabled, + "interval": *log.EmitInterval, + "bucket": *log.S3BucketName, + "bucket_prefix": *log.S3BucketPrefix, + }) + } + + return result +} + // Flattens a health check into something that flatmap.Flatten() // can handle func flattenHealthCheck(check *elb.HealthCheck) []map[string]interface{} {