aws: fix build after upstream breaking change

see
1a69d06935
This commit is contained in:
Paul Hinze 2015-10-29 18:52:10 -05:00
parent 9428e9f1d1
commit cadbbbae08
2 changed files with 32 additions and 25 deletions

View File

@ -11,6 +11,7 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/autoscaling" "github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/aws/aws-sdk-go/service/cloudformation" "github.com/aws/aws-sdk-go/service/cloudformation"
"github.com/aws/aws-sdk-go/service/cloudtrail" "github.com/aws/aws-sdk-go/service/cloudtrail"
@ -110,7 +111,8 @@ func (c *Config) Client() (interface{}, error) {
} }
log.Println("[INFO] Initializing IAM Connection") log.Println("[INFO] Initializing IAM Connection")
client.iamconn = iam.New(awsConfig) sess := session.New(awsConfig)
client.iamconn = iam.New(sess)
err := c.ValidateCredentials(client.iamconn) err := c.ValidateCredentials(client.iamconn)
if err != nil { if err != nil {
@ -128,33 +130,36 @@ func (c *Config) Client() (interface{}, error) {
MaxRetries: aws.Int(c.MaxRetries), MaxRetries: aws.Int(c.MaxRetries),
HTTPClient: cleanhttp.DefaultClient(), HTTPClient: cleanhttp.DefaultClient(),
} }
usEast1Sess := session.New(usEast1AwsConfig)
awsDynamoDBConfig := *awsConfig awsDynamoDBConfig := *awsConfig
awsDynamoDBConfig.Endpoint = aws.String(c.DynamoDBEndpoint) awsDynamoDBConfig.Endpoint = aws.String(c.DynamoDBEndpoint)
log.Println("[INFO] Initializing DynamoDB connection") log.Println("[INFO] Initializing DynamoDB connection")
client.dynamodbconn = dynamodb.New(&awsDynamoDBConfig) dynamoSess := session.New(&awsDynamoDBConfig)
client.dynamodbconn = dynamodb.New(dynamoSess)
log.Println("[INFO] Initializing ELB connection") log.Println("[INFO] Initializing ELB connection")
client.elbconn = elb.New(awsConfig) client.elbconn = elb.New(sess)
log.Println("[INFO] Initializing S3 connection") log.Println("[INFO] Initializing S3 connection")
client.s3conn = s3.New(awsConfig) client.s3conn = s3.New(sess)
log.Println("[INFO] Initializing SQS connection") log.Println("[INFO] Initializing SQS connection")
client.sqsconn = sqs.New(awsConfig) client.sqsconn = sqs.New(sess)
log.Println("[INFO] Initializing SNS connection") log.Println("[INFO] Initializing SNS connection")
client.snsconn = sns.New(awsConfig) client.snsconn = sns.New(sess)
log.Println("[INFO] Initializing RDS Connection") log.Println("[INFO] Initializing RDS Connection")
client.rdsconn = rds.New(awsConfig) client.rdsconn = rds.New(sess)
awsKinesisConfig := *awsConfig awsKinesisConfig := *awsConfig
awsKinesisConfig.Endpoint = aws.String(c.KinesisEndpoint) awsKinesisConfig.Endpoint = aws.String(c.KinesisEndpoint)
log.Println("[INFO] Initializing Kinesis Connection") log.Println("[INFO] Initializing Kinesis Connection")
client.kinesisconn = kinesis.New(&awsKinesisConfig) kinesisSess := session.New(&awsKinesisConfig)
client.kinesisconn = kinesis.New(kinesisSess)
authErr := c.ValidateAccountId(client.iamconn) authErr := c.ValidateAccountId(client.iamconn)
if authErr != nil { if authErr != nil {
@ -162,52 +167,52 @@ func (c *Config) Client() (interface{}, error) {
} }
log.Println("[INFO] Initializing AutoScaling connection") log.Println("[INFO] Initializing AutoScaling connection")
client.autoscalingconn = autoscaling.New(awsConfig) client.autoscalingconn = autoscaling.New(sess)
log.Println("[INFO] Initializing EC2 Connection") log.Println("[INFO] Initializing EC2 Connection")
client.ec2conn = ec2.New(awsConfig) client.ec2conn = ec2.New(sess)
log.Println("[INFO] Initializing ECS Connection") log.Println("[INFO] Initializing ECS Connection")
client.ecsconn = ecs.New(awsConfig) client.ecsconn = ecs.New(sess)
log.Println("[INFO] Initializing EFS Connection") log.Println("[INFO] Initializing EFS Connection")
client.efsconn = efs.New(awsConfig) client.efsconn = efs.New(sess)
log.Println("[INFO] Initializing ElasticSearch Connection") log.Println("[INFO] Initializing ElasticSearch Connection")
client.esconn = elasticsearch.New(awsConfig) client.esconn = elasticsearch.New(sess)
log.Println("[INFO] Initializing Route 53 connection") log.Println("[INFO] Initializing Route 53 connection")
client.r53conn = route53.New(usEast1AwsConfig) client.r53conn = route53.New(usEast1Sess)
log.Println("[INFO] Initializing Elasticache Connection") log.Println("[INFO] Initializing Elasticache Connection")
client.elasticacheconn = elasticache.New(awsConfig) client.elasticacheconn = elasticache.New(sess)
log.Println("[INFO] Initializing Lambda Connection") log.Println("[INFO] Initializing Lambda Connection")
client.lambdaconn = lambda.New(awsConfig) client.lambdaconn = lambda.New(sess)
log.Println("[INFO] Initializing Cloudformation Connection") log.Println("[INFO] Initializing Cloudformation Connection")
client.cfconn = cloudformation.New(awsConfig) client.cfconn = cloudformation.New(sess)
log.Println("[INFO] Initializing CloudWatch SDK connection") log.Println("[INFO] Initializing CloudWatch SDK connection")
client.cloudwatchconn = cloudwatch.New(awsConfig) client.cloudwatchconn = cloudwatch.New(sess)
log.Println("[INFO] Initializing CloudTrail connection") log.Println("[INFO] Initializing CloudTrail connection")
client.cloudtrailconn = cloudtrail.New(awsConfig) client.cloudtrailconn = cloudtrail.New(sess)
log.Println("[INFO] Initializing CloudWatch Logs connection") log.Println("[INFO] Initializing CloudWatch Logs connection")
client.cloudwatchlogsconn = cloudwatchlogs.New(awsConfig) client.cloudwatchlogsconn = cloudwatchlogs.New(sess)
log.Println("[INFO] Initializing OpsWorks Connection") log.Println("[INFO] Initializing OpsWorks Connection")
client.opsworksconn = opsworks.New(usEast1AwsConfig) client.opsworksconn = opsworks.New(usEast1Sess)
log.Println("[INFO] Initializing Directory Service connection") log.Println("[INFO] Initializing Directory Service connection")
client.dsconn = directoryservice.New(awsConfig) client.dsconn = directoryservice.New(sess)
log.Println("[INFO] Initializing Glacier connection") log.Println("[INFO] Initializing Glacier connection")
client.glacierconn = glacier.New(awsConfig) client.glacierconn = glacier.New(sess)
log.Println("[INFO] Initializing CodeDeploy Connection") log.Println("[INFO] Initializing CodeDeploy Connection")
client.codedeployconn = codedeploy.New(awsConfig) client.codedeployconn = codedeploy.New(sess)
} }
if len(errs) > 0 { if len(errs) > 0 {

View File

@ -12,6 +12,7 @@ import (
"github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds" "github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3" "github.com/aws/aws-sdk-go/service/s3"
"github.com/hashicorp/go-cleanhttp" "github.com/hashicorp/go-cleanhttp"
) )
@ -78,7 +79,8 @@ func s3Factory(conf map[string]string) (Client, error) {
Region: aws.String(regionName), Region: aws.String(regionName),
HTTPClient: cleanhttp.DefaultClient(), HTTPClient: cleanhttp.DefaultClient(),
} }
nativeClient := s3.New(awsConfig) sess := session.New(awsConfig)
nativeClient := s3.New(sess)
return &S3Client{ return &S3Client{
nativeClient: nativeClient, nativeClient: nativeClient,