Skip to content

Commit

Permalink
Update depedencies and use NewSession to generate aws sessions
Browse files Browse the repository at this point in the history
Due to the way the AWS's pod identity webhook provides authentication
tokens to pods, we need to upgrade `aws-sdk-go` as per
https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts-minimum-sdk.html
and use replace the deprecated New func with NewSession to properly load the
identity file as detailed in this issue:
kubernetes/autoscaler#2428
  • Loading branch information
andrewward committed Aug 28, 2020
1 parent bb1573e commit 2bc03ea
Show file tree
Hide file tree
Showing 4 changed files with 379 additions and 11 deletions.
4 changes: 2 additions & 2 deletions collector/aws_ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type AWSEC2InstanceGatherer interface {
// NewAWSEC2Client creates a new AWS EC2 API client
func NewAWSEC2Client(awsRegion string) (*AWSEC2Client, error) {
// Create AWS session
s := session.New(&aws.Config{Region: aws.String(awsRegion)})
if s == nil {
s, err := session.NewSession(&aws.Config{Region: aws.String(awsRegion)})
if err != nil {
return nil, fmt.Errorf("Error creating AWS session")
}

Expand Down
4 changes: 2 additions & 2 deletions collector/aws_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ type AWSLogsClient struct {
// NewAWSLogsClient creates a new AWS CloudWatch Logs API client
func NewAWSLogsClient(awsRegion string, logGroupNamePrefix *string) (*AWSLogsClient, error) {
// Create AWS session
s := session.New(&aws.Config{Region: aws.String(awsRegion)})
if s == nil {
s, err := session.NewSession(&aws.Config{Region: aws.String(awsRegion)})
if err != nil {
return nil, fmt.Errorf("error creating aws session")
}

Expand Down
15 changes: 8 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module github.com/kpettijohn/cwlogstream_exporter

require (
github.com/aws/aws-sdk-go v1.19.36
github.com/prometheus/client_golang v0.9.3
github.com/prometheus/common v0.4.1
github.com/prometheus/procfs v0.0.0-20190522114515-bc1a522cf7b1 // indirect
github.com/sirupsen/logrus v1.2.0
github.com/stretchr/testify v1.3.0 // indirect
golang.org/x/net v0.0.0-20190522155817-f3200d17e092 // indirect
github.com/aws/aws-sdk-go v1.34.12
github.com/prometheus/client_golang v1.7.1
github.com/prometheus/common v0.13.0
github.com/prometheus/tsdb v0.7.1 // indirect
github.com/sirupsen/logrus v1.6.0
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a // indirect
golang.org/x/sys v0.0.0-20200828161417-c663848e9a16 // indirect
golang.org/x/text v0.3.2 // indirect
google.golang.org/protobuf v1.25.0 // indirect
)
Loading

0 comments on commit 2bc03ea

Please sign in to comment.