@@ -11,6 +11,7 @@ import (
1111 "github.com/aws/aws-sdk-go/aws"
1212 "github.com/aws/aws-sdk-go/aws/awserr"
1313 "github.com/aws/aws-sdk-go/aws/credentials"
14+ "github.com/aws/aws-sdk-go/aws/session"
1415 "github.com/aws/aws-sdk-go/service/autoscaling"
1516 "github.com/aws/aws-sdk-go/service/cloudformation"
1617 "github.com/aws/aws-sdk-go/service/cloudtrail"
@@ -110,7 +111,8 @@ func (c *Config) Client() (interface{}, error) {
110111 }
111112
112113 log .Println ("[INFO] Initializing IAM Connection" )
113- client .iamconn = iam .New (awsConfig )
114+ sess := session .New (awsConfig )
115+ client .iamconn = iam .New (sess )
114116
115117 err := c .ValidateCredentials (client .iamconn )
116118 if err != nil {
@@ -128,86 +130,89 @@ func (c *Config) Client() (interface{}, error) {
128130 MaxRetries : aws .Int (c .MaxRetries ),
129131 HTTPClient : cleanhttp .DefaultClient (),
130132 }
133+ usEast1Sess := session .New (usEast1AwsConfig )
131134
132135 awsDynamoDBConfig := * awsConfig
133136 awsDynamoDBConfig .Endpoint = aws .String (c .DynamoDBEndpoint )
134137
135138 log .Println ("[INFO] Initializing DynamoDB connection" )
136- client .dynamodbconn = dynamodb .New (& awsDynamoDBConfig )
139+ dynamoSess := session .New (& awsDynamoDBConfig )
140+ client .dynamodbconn = dynamodb .New (dynamoSess )
137141
138142 log .Println ("[INFO] Initializing ELB connection" )
139- client .elbconn = elb .New (awsConfig )
143+ client .elbconn = elb .New (sess )
140144
141145 log .Println ("[INFO] Initializing S3 connection" )
142- client .s3conn = s3 .New (awsConfig )
146+ client .s3conn = s3 .New (sess )
143147
144148 log .Println ("[INFO] Initializing SQS connection" )
145- client .sqsconn = sqs .New (awsConfig )
149+ client .sqsconn = sqs .New (sess )
146150
147151 log .Println ("[INFO] Initializing SNS connection" )
148- client .snsconn = sns .New (awsConfig )
152+ client .snsconn = sns .New (sess )
149153
150154 log .Println ("[INFO] Initializing RDS Connection" )
151- client .rdsconn = rds .New (awsConfig )
155+ client .rdsconn = rds .New (sess )
152156
153157 awsKinesisConfig := * awsConfig
154158 awsKinesisConfig .Endpoint = aws .String (c .KinesisEndpoint )
155159
156160 log .Println ("[INFO] Initializing Kinesis Connection" )
157- client .kinesisconn = kinesis .New (& awsKinesisConfig )
161+ kinesisSess := session .New (& awsKinesisConfig )
162+ client .kinesisconn = kinesis .New (kinesisSess )
158163
159164 authErr := c .ValidateAccountId (client .iamconn )
160165 if authErr != nil {
161166 errs = append (errs , authErr )
162167 }
163168
164169 log .Println ("[INFO] Initializing AutoScaling connection" )
165- client .autoscalingconn = autoscaling .New (awsConfig )
170+ client .autoscalingconn = autoscaling .New (sess )
166171
167172 log .Println ("[INFO] Initializing EC2 Connection" )
168- client .ec2conn = ec2 .New (awsConfig )
173+ client .ec2conn = ec2 .New (sess )
169174
170175 log .Println ("[INFO] Initializing ECS Connection" )
171- client .ecsconn = ecs .New (awsConfig )
176+ client .ecsconn = ecs .New (sess )
172177
173178 log .Println ("[INFO] Initializing EFS Connection" )
174- client .efsconn = efs .New (awsConfig )
179+ client .efsconn = efs .New (sess )
175180
176181 log .Println ("[INFO] Initializing ElasticSearch Connection" )
177- client .esconn = elasticsearch .New (awsConfig )
182+ client .esconn = elasticsearch .New (sess )
178183
179184 log .Println ("[INFO] Initializing Route 53 connection" )
180- client .r53conn = route53 .New (usEast1AwsConfig )
185+ client .r53conn = route53 .New (usEast1Sess )
181186
182187 log .Println ("[INFO] Initializing Elasticache Connection" )
183- client .elasticacheconn = elasticache .New (awsConfig )
188+ client .elasticacheconn = elasticache .New (sess )
184189
185190 log .Println ("[INFO] Initializing Lambda Connection" )
186- client .lambdaconn = lambda .New (awsConfig )
191+ client .lambdaconn = lambda .New (sess )
187192
188193 log .Println ("[INFO] Initializing Cloudformation Connection" )
189- client .cfconn = cloudformation .New (awsConfig )
194+ client .cfconn = cloudformation .New (sess )
190195
191196 log .Println ("[INFO] Initializing CloudWatch SDK connection" )
192- client .cloudwatchconn = cloudwatch .New (awsConfig )
197+ client .cloudwatchconn = cloudwatch .New (sess )
193198
194199 log .Println ("[INFO] Initializing CloudTrail connection" )
195- client .cloudtrailconn = cloudtrail .New (awsConfig )
200+ client .cloudtrailconn = cloudtrail .New (sess )
196201
197202 log .Println ("[INFO] Initializing CloudWatch Logs connection" )
198- client .cloudwatchlogsconn = cloudwatchlogs .New (awsConfig )
203+ client .cloudwatchlogsconn = cloudwatchlogs .New (sess )
199204
200205 log .Println ("[INFO] Initializing OpsWorks Connection" )
201- client .opsworksconn = opsworks .New (usEast1AwsConfig )
206+ client .opsworksconn = opsworks .New (usEast1Sess )
202207
203208 log .Println ("[INFO] Initializing Directory Service connection" )
204- client .dsconn = directoryservice .New (awsConfig )
209+ client .dsconn = directoryservice .New (sess )
205210
206211 log .Println ("[INFO] Initializing Glacier connection" )
207- client .glacierconn = glacier .New (awsConfig )
212+ client .glacierconn = glacier .New (sess )
208213
209214 log .Println ("[INFO] Initializing CodeDeploy Connection" )
210- client .codedeployconn = codedeploy .New (awsConfig )
215+ client .codedeployconn = codedeploy .New (sess )
211216 }
212217
213218 if len (errs ) > 0 {
0 commit comments