aws: Improve formatting of debug logs

This commit is contained in:
Radek Simko 2015-07-12 15:34:58 +01:00
parent 9882cc59d8
commit c4a2df9e93
3 changed files with 13 additions and 10 deletions

View File

@ -6,6 +6,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/awsutil"
"github.com/aws/aws-sdk-go/service/ecs"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
@ -57,7 +58,7 @@ func resourceAwsEcsClusterRead(d *schema.ResourceData, meta interface{}) error {
if err != nil {
return err
}
log.Printf("[DEBUG] Received ECS clusters: %#v", out.Clusters)
log.Printf("[DEBUG] Received ECS clusters: %s", awsutil.StringValue(out.Clusters))
d.SetId(*out.Clusters[0].ClusterARN)
d.Set("name", *out.Clusters[0].ClusterName)
@ -76,7 +77,7 @@ func resourceAwsEcsClusterDelete(d *schema.ResourceData, meta interface{}) error
})
if err == nil {
log.Printf("[DEBUG] ECS cluster %s deleted: %#v", d.Id(), out)
log.Printf("[DEBUG] ECS cluster %s deleted: %s", d.Id(), awsutil.StringValue(out))
return nil
}

View File

@ -9,6 +9,7 @@ import (
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awsutil"
"github.com/aws/aws-sdk-go/service/ecs"
"github.com/aws/aws-sdk-go/service/iam"
"github.com/hashicorp/terraform/helper/hashcode"
@ -97,14 +98,14 @@ func resourceAwsEcsServiceCreate(d *schema.ResourceData, meta interface{}) error
loadBalancers := expandEcsLoadBalancers(d.Get("load_balancer").(*schema.Set).List())
if len(loadBalancers) > 0 {
log.Printf("[DEBUG] Adding ECS load balancers: %#v", loadBalancers)
log.Printf("[DEBUG] Adding ECS load balancers: %s", awsutil.StringValue(loadBalancers))
input.LoadBalancers = loadBalancers
}
if v, ok := d.GetOk("iam_role"); ok {
input.Role = aws.String(v.(string))
}
log.Printf("[DEBUG] Creating ECS service: %#v", input)
log.Printf("[DEBUG] Creating ECS service: %s", awsutil.StringValue(input))
out, err := conn.CreateService(&input)
if err != nil {
return err
@ -138,7 +139,7 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error {
}
service := out.Services[0]
log.Printf("[DEBUG] Received ECS service %#v", service)
log.Printf("[DEBUG] Received ECS service %s", awsutil.StringValue(service))
d.SetId(*service.ServiceARN)
d.Set("name", *service.ServiceName)
@ -188,7 +189,7 @@ func resourceAwsEcsServiceUpdate(d *schema.ResourceData, meta interface{}) error
return err
}
service := out.Service
log.Printf("[DEBUG] Updated ECS service %#v", service)
log.Printf("[DEBUG] Updated ECS service %s", awsutil.StringValue(service))
return resourceAwsEcsServiceRead(d, meta)
}
@ -228,7 +229,7 @@ func resourceAwsEcsServiceDelete(d *schema.ResourceData, meta interface{}) error
Cluster: aws.String(d.Get("cluster").(string)),
}
log.Printf("[DEBUG] Deleting ECS service %#v", input)
log.Printf("[DEBUG] Deleting ECS service %s", awsutil.StringValue(input))
out, err := conn.DeleteService(&input)
if err != nil {
return err

View File

@ -8,6 +8,7 @@ import (
"log"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awsutil"
"github.com/aws/aws-sdk-go/service/ecs"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
@ -90,7 +91,7 @@ func resourceAwsEcsTaskDefinitionCreate(d *schema.ResourceData, meta interface{}
input.Volumes = volumes
}
log.Printf("[DEBUG] Registering ECS task definition: %#v", input)
log.Printf("[DEBUG] Registering ECS task definition: %s", awsutil.StringValue(input))
out, err := conn.RegisterTaskDefinition(&input)
if err != nil {
return err
@ -98,7 +99,7 @@ func resourceAwsEcsTaskDefinitionCreate(d *schema.ResourceData, meta interface{}
taskDefinition := *out.TaskDefinition
log.Printf("[DEBUG] ECS task definition registered: %#v (rev. %d)",
log.Printf("[DEBUG] ECS task definition registered: %q (rev. %d)",
*taskDefinition.TaskDefinitionARN, *taskDefinition.Revision)
d.SetId(*taskDefinition.Family)
@ -117,7 +118,7 @@ func resourceAwsEcsTaskDefinitionRead(d *schema.ResourceData, meta interface{})
if err != nil {
return err
}
log.Printf("[DEBUG] Received task definition %#v", out)
log.Printf("[DEBUG] Received task definition %s", awsutil.StringValue(out))
taskDefinition := out.TaskDefinition