go fmt after rebase
This commit is contained in:
parent
4e3d0b5f6c
commit
2e03a7ebff
|
@ -101,35 +101,35 @@ func resourceAwsElb() *schema.Resource {
|
|||
Default: 300,
|
||||
},
|
||||
|
||||
"access_logs": &schema.Schema{
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"enabled": &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: true,
|
||||
},
|
||||
"interval": &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Default: 60,
|
||||
},
|
||||
"bucket": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
"bucket_prefix": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
Set: resourceAwsElbAccessLogsHash,
|
||||
},
|
||||
"access_logs": &schema.Schema{
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"enabled": &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: true,
|
||||
},
|
||||
"interval": &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Default: 60,
|
||||
},
|
||||
"bucket": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
"bucket_prefix": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
Set: resourceAwsElbAccessLogsHash,
|
||||
},
|
||||
|
||||
"listener": &schema.Schema{
|
||||
"listener": &schema.Schema{
|
||||
Type: schema.TypeSet,
|
||||
Required: true,
|
||||
Elem: &schema.Resource{
|
||||
|
@ -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", flattenAccessLog(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
|
||||
|
@ -434,7 +434,7 @@ func resourceAwsElbUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
d.SetPartial("instances")
|
||||
}
|
||||
|
||||
if d.HasChange("cross_zone_load_balancing") || d.HasChange("idle_timeout") || d.HasChange("access_logs") {
|
||||
if d.HasChange("cross_zone_load_balancing") || d.HasChange("idle_timeout") || d.HasChange("access_logs") {
|
||||
attrs := elb.ModifyLoadBalancerAttributesInput{
|
||||
LoadBalancerName: aws.String(d.Get("name").(string)),
|
||||
LoadBalancerAttributes: &elb.LoadBalancerAttributes{
|
||||
|
@ -445,25 +445,25 @@ func resourceAwsElbUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
IdleTimeout: aws.Int64(int64(d.Get("idle_timeout").(int))),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
logs := d.Get("access_logs").(*schema.Set).List()
|
||||
if len(logs) > 1 {
|
||||
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{
|
||||
Enabled: aws.Bool(log["enabled"].(bool)),
|
||||
EmitInterval: aws.Int64(int64(log["interval"].(int))),
|
||||
S3BucketName: aws.String(log["bucket"].(string)),
|
||||
}
|
||||
logs := d.Get("access_logs").(*schema.Set).List()
|
||||
if len(logs) > 1 {
|
||||
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{
|
||||
Enabled: aws.Bool(log["enabled"].(bool)),
|
||||
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))
|
||||
}
|
||||
if log["bucket_prefix"] != "" {
|
||||
accessLogs.S3BucketPrefix = aws.String(log["bucket_prefix"].(string))
|
||||
}
|
||||
|
||||
attrs.LoadBalancerAttributes.AccessLog = accessLogs
|
||||
}
|
||||
attrs.LoadBalancerAttributes.AccessLog = accessLogs
|
||||
}
|
||||
|
||||
_, err := elbconn.ModifyLoadBalancerAttributes(&attrs)
|
||||
if err != nil {
|
||||
|
@ -598,17 +598,17 @@ func resourceAwsElbHealthCheckHash(v interface{}) int {
|
|||
}
|
||||
|
||||
func resourceAwsElbAccessLogsHash(v interface{}) int {
|
||||
var buf bytes.Buffer
|
||||
m := v.(map[string]interface{})
|
||||
buf.WriteString(fmt.Sprintf("%t-", m["enabled"].(bool)))
|
||||
buf.WriteString(fmt.Sprintf("%d-", m["interval"].(int)))
|
||||
buf.WriteString(fmt.Sprintf("%s-",
|
||||
strings.ToLower(m["bucket"].(string))))
|
||||
if v, ok := m["bucket_prefix"]; ok {
|
||||
buf.WriteString(fmt.Sprintf("%s-", strings.ToLower(v.(string))))
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
m := v.(map[string]interface{})
|
||||
buf.WriteString(fmt.Sprintf("%t-", m["enabled"].(bool)))
|
||||
buf.WriteString(fmt.Sprintf("%d-", m["interval"].(int)))
|
||||
buf.WriteString(fmt.Sprintf("%s-",
|
||||
strings.ToLower(m["bucket"].(string))))
|
||||
if v, ok := m["bucket_prefix"]; ok {
|
||||
buf.WriteString(fmt.Sprintf("%s-", strings.ToLower(v.(string))))
|
||||
}
|
||||
|
||||
return hashcode.String(buf.String())
|
||||
return hashcode.String(buf.String())
|
||||
}
|
||||
|
||||
func resourceAwsElbListenerHash(v interface{}) int {
|
||||
|
|
|
@ -236,18 +236,18 @@ func expandElastiCacheParameters(configured []interface{}) ([]*elasticache.Param
|
|||
|
||||
// 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)
|
||||
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,
|
||||
})
|
||||
}
|
||||
if log != nil {
|
||||
result = append(result, map[string]interface{}{
|
||||
"enabled": *log.Enabled,
|
||||
"interval": *log.EmitInterval,
|
||||
"bucket": *log.S3BucketName,
|
||||
"bucket_prefix": *log.S3BucketPrefix,
|
||||
})
|
||||
}
|
||||
|
||||
return result
|
||||
return result
|
||||
}
|
||||
|
||||
// Flattens a health check into something that flatmap.Flatten()
|
||||
|
|
Loading…
Reference in New Issue