Skip to content

Commit

Permalink
return err if we fail to set access_logs; other cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
catsby committed Nov 10, 2015
1 parent 0a1890c commit 8c32536
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions builtin/providers/aws/resource_aws_elb.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error {
d.Set("connection_draining_timeout", lbAttrs.ConnectionDraining.Timeout)
if lbAttrs.AccessLog != nil {
if err := d.Set("access_logs", flattenAccessLog(lbAttrs.AccessLog)); err != nil {
log.Printf("[WARN] Error setting ELB Access Logs for (%s): %s", d.Id(), err)
return err
}
}

Expand Down Expand Up @@ -469,17 +469,17 @@ func resourceAwsElbUpdate(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Only one access logs config per ELB is supported")
} else if len(logs) == 1 {
log := logs[0].(map[string]interface{})
accessLogs := &elb.AccessLog{
accessLog := &elb.AccessLog{
Enabled: aws.Bool(true),
EmitInterval: aws.Int64(int64(log["interval"].(int))),
S3BucketName: aws.String(log["bucket"].(string)),
}

if log["bucket_prefix"] != "" {
accessLogs.S3BucketPrefix = aws.String(log["bucket_prefix"].(string))
accessLog.S3BucketPrefix = aws.String(log["bucket_prefix"].(string))
}

attrs.LoadBalancerAttributes.AccessLog = accessLogs
attrs.LoadBalancerAttributes.AccessLog = accessLog
} else if len(logs) == 0 {
// disable access logs
attrs.LoadBalancerAttributes.AccessLog = &elb.AccessLog{
Expand Down

0 comments on commit 8c32536

Please sign in to comment.