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 e9de69d commit ef8aae9
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 @@ -39,6 +40,7 @@ func (c *Config) loadAndValidate(providerCode string) (interface{}, error) {
var err error
var errs []error

c.tryLoadingDeprecatedEnvVars()
credsProvider, err := c.getCredsProvider(providerCode)
if err != nil {
errs = append(errs, err)
Expand All @@ -57,6 +59,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 ef8aae9

Please sign in to comment.