Skip to content

Commit

Permalink
Compatibility layer with goamz added
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Mar 19, 2015
1 parent a7dbdfb commit 044f3c9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions builtin/providers/aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package aws
import (
"fmt"
"log"
"os"
"time"

"github.com/hashicorp/aws-sdk-go/aws"
Expand Down Expand Up @@ -36,6 +37,7 @@ type AWSClient struct {
}

func (c *Config) loadAndValidate(providerCode string) (interface{}, error) {
c.tryLoadingDeprecatedEnvVars()
credsProvider, err := c.getCredsProvider(providerCode)
if err != nil {
return nil, err
Expand All @@ -50,6 +52,19 @@ func (c *Config) loadAndValidate(providerCode string) (interface{}, error) {
return c.Client()
}

func (c *Config) tryLoadingDeprecatedEnvVars() {
// Backward compatibility
if c.Token == "" {
c.Token = os.Getenv("AWS_SECURITY_TOKEN")
}
if c.CredentialsFilePath == "" {
c.CredentialsFilePath = os.Getenv("AWS_CREDENTIAL_FILE")
}
if c.CredentialsFileProfile == "" {
c.CredentialsFileProfile = os.Getenv("AWS_PROFILE")
}
}

func (c *Config) getCredsProvider(providerCode string) (aws.CredentialsProvider, error) {
if providerCode == "static" {
return aws.Creds(c.AccessKey, c.SecretKey, c.Token), nil
Expand Down

0 comments on commit 044f3c9

Please sign in to comment.