return err if we fail to set access_logs; other cleanups

This commit is contained in:
clint shryock 2015-11-10 16:58:24 -06:00
parent 0a1890c329
commit 8c32536f3d
1 changed files with 4 additions and 4 deletions

View File

@ -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
}
}
@ -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{