Allow Debug messages from ec2 driver to include request / response data sent to aws.

Signed-off-by: Jeffrey Ellin <jeff@ellin.com>
This commit is contained in:
jellin 2016-01-12 14:16:37 -05:00
parent e0570c0c2b
commit 6d41d8c1ad
2 changed files with 24 additions and 0 deletions

View File

@ -655,8 +655,11 @@ func (d *Driver) Remove() error {
func (d *Driver) getClient() *ec2.EC2 {
config := aws.NewConfig()
alogger := AwsLogger()
config = config.WithRegion(d.Region)
config = config.WithCredentials(credentials.NewStaticCredentials(d.AccessKey, d.SecretKey, d.SessionToken))
config = config.WithLogger(alogger)
config = config.WithLogLevel(aws.LogDebugWithHTTPBody)
return ec2.New(session.New(config))
}

View File

@ -0,0 +1,21 @@
package amazonec2
import (
"github.com/aws/aws-sdk-go/aws"
"log"
"os"
)
type awslogger struct {
logger *log.Logger
}
func AwsLogger() aws.Logger {
return &awslogger{
logger: log.New(os.Stderr, "", log.LstdFlags),
}
}
func (l awslogger) Log(args ...interface{}) {
l.logger.Println(args...)
}