Skip to content

Commit

Permalink
Merge pull request #3281 from justinsb/aws_session_always_verbose
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

AWS: Always use verbose errors
  • Loading branch information
Kubernetes Submit Queue authored Aug 28, 2017
2 parents 0c72684 + a26b285 commit f123138
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
8 changes: 4 additions & 4 deletions protokube/pkg/protokube/aws_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ func NewAWSVolumes() (*AWSVolumes, error) {
deviceMap: make(map[string]string),
}

s, err := session.NewSession()
config := aws.NewConfig()
config = config.WithCredentialsChainVerboseErrors(true)

s, err := session.NewSession(config)
if err != nil {
return nil, fmt.Errorf("error starting new AWS session: %v", err)
}
Expand All @@ -67,9 +70,6 @@ func NewAWSVolumes() (*AWSVolumes, error) {
glog.V(4).Infof("AWS API Request: %s/%s", r.ClientInfo.ServiceName, r.Operation.Name)
})

config := aws.NewConfig()
config = config.WithCredentialsChainVerboseErrors(true)

a.metadata = ec2metadata.New(s, config)

region, err := a.metadata.Region()
Expand Down
12 changes: 6 additions & 6 deletions upup/pkg/fi/cloudup/awsup/aws_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,42 +168,42 @@ func NewAWSCloud(region string, tags map[string]string) (AWSCloud, error) {

requestLogger := newRequestLogger(2)

sess, err := session.NewSession()
sess, err := session.NewSession(config)
if err != nil {
return c, err
}
c.cf = cloudformation.New(sess, config)
c.cf.Handlers.Send.PushFront(requestLogger)

sess, err = session.NewSession()
sess, err = session.NewSession(config)
if err != nil {
return c, err
}
c.ec2 = ec2.New(sess, config)
c.ec2.Handlers.Send.PushFront(requestLogger)

sess, err = session.NewSession()
sess, err = session.NewSession(config)
if err != nil {
return c, err
}
c.iam = iam.New(sess, config)
c.iam.Handlers.Send.PushFront(requestLogger)

sess, err = session.NewSession()
sess, err = session.NewSession(config)
if err != nil {
return c, err
}
c.elb = elb.New(sess, config)
c.elb.Handlers.Send.PushFront(requestLogger)

sess, err = session.NewSession()
sess, err = session.NewSession(config)
if err != nil {
return c, err
}
c.autoscaling = autoscaling.New(sess, config)
c.autoscaling.Handlers.Send.PushFront(requestLogger)

sess, err = session.NewSession()
sess, err = session.NewSession(config)
if err != nil {
return c, err
}
Expand Down
2 changes: 1 addition & 1 deletion upup/pkg/fi/cloudup/awsup/aws_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func ValidateRegion(region string) error {
config := aws.NewConfig().WithRegion(awsRegion)
config = config.WithCredentialsChainVerboseErrors(true)

sess, err := session.NewSession()
sess, err := session.NewSession(config)
if err != nil {
return fmt.Errorf("Error starting a new AWS session: %v", err)
}
Expand Down
10 changes: 7 additions & 3 deletions util/pkg/vfs/s3context.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ func (s *S3Context) getClient(region string) (*s3.S3, error) {
}
}

sess, err := session.NewSession()
sess, err := session.NewSession(config)
if err != nil {
return nil, fmt.Errorf("error starting new AWS session:%v", err)
return nil, fmt.Errorf("error starting new AWS session: %v", err)
}
s3Client = s3.New(sess, config)
s.clients[region] = s3Client
Expand All @@ -92,6 +92,7 @@ func getCustomS3Config(endpoint string, region string) (*aws.Config, error) {
Region: aws.String(region),
S3ForcePathStyle: aws.Bool(true),
}
s3Config = s3Config.WithCredentialsChainVerboseErrors(true)

return s3Config, nil
}
Expand Down Expand Up @@ -181,7 +182,10 @@ out the first result.
See also: https://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/GetBucketLocationRequest
*/
func bruteforceBucketLocation(region *string, request *s3.GetBucketLocationInput) (*s3.GetBucketLocationOutput, error) {
session, _ := session.NewSession(&aws.Config{Region: region})
config := &aws.Config{Region: region}
config = config.WithCredentialsChainVerboseErrors(true)

session, _ := session.NewSession(config)

regions, err := ec2.New(session).DescribeRegions(nil)
if err != nil {
Expand Down

0 comments on commit f123138

Please sign in to comment.