Merge pull request #2818 from jeffellin/debugaws

Allow Debug messages from ec2 driver to include request / response
This commit is contained in:
David Gageot 2016-01-13 09:13:55 +01:00
commit b589eb9475
2 changed files with 24 additions and 0 deletions

View File

@ -663,8 +663,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...)
}