Skip to content

Commit

Permalink
Use default credentials provider chain (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduardo Lopez authored and holtwilkins committed Aug 21, 2018
1 parent 49d5adc commit 406ff76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 4 additions & 15 deletions aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"time"

"github.com/aws/aws-sdk-go/aws"
"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/ec2"
Expand All @@ -36,28 +35,18 @@ type Clients struct {

// GetAWSClients returns the AWS client objects we'll need
func GetAWSClients() (*Clients, error) {
c := credentials.NewEnvCredentials()

_, err := c.Get()
if err != nil {
return nil, errors.Wrap(err, "error getting AWS creds")
}

if c.IsExpired() {
return nil, errors.Errorf("Your AWS Credentials are expired")
}

region := os.Getenv("AWS_DEFAULT_REGION")
if region == "" {
region = "us-east-1"
}

awsConf := aws.Config{
Credentials: c,
Region: &region,
Region: &region,
}

sess, err := session.NewSession(&awsConf)
sess, err := session.NewSessionWithOptions(session.Options{
Config: awsConf,
})
if err != nil {
return nil, errors.Wrap(err, "Error opening AWS session")
}
Expand Down

0 comments on commit 406ff76

Please sign in to comment.