Skip to content

Commit

Permalink
Credentials loading via aws-sdk-go takes priority over goamz
Browse files Browse the repository at this point in the history
 - The new library effectively brings following functionality:
   - load credentials from file at standard locations
   - use MFA session token with up-to-date naming convention
  • Loading branch information
Radek Simko committed Feb 25, 2015
1 parent 9cb52a3 commit 1254017
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions builtin/providers/aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,17 @@ type AWSClient struct {
// Client configures and returns a fully initailized AWSClient
func (c *Config) Client() (interface{}, error) {
var client AWSClient
var errs []error

log.Println("[INFO] Detecting AWS creds via aws-sdk-go")
credsProvider := awsGo.DetectCreds(c.AccessKey, c.SecretKey, "")
_, err := credsProvider.Credentials()
if err != nil {
errs = append(errs, err)
}

// Get the auth and region. This can fail if keys/regions were not
// specified and we're attempting to use the environment.
var errs []error
log.Println("[INFO] Building AWS auth structure via goamz")
auth, err := c.AWSAuth()
if err != nil {
Expand All @@ -58,8 +65,6 @@ func (c *Config) Client() (interface{}, error) {
// bucket storage in S3
client.region = c.Region

credsProvider := awsGo.Creds(c.AccessKey, c.SecretKey, "")

log.Println("[INFO] Initializing EC2 connection")
client.ec2conn = ec2.New(auth, region)
log.Println("[INFO] Initializing ELB connection")
Expand Down

0 comments on commit 1254017

Please sign in to comment.