From 54358155247ce1630e89ffdac68cc5e3696275e5 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Tue, 5 May 2015 20:30:35 +0200 Subject: [PATCH 1/2] Fixing PR #1804 --- state/remote/s3.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/state/remote/s3.go b/state/remote/s3.go index efe131be166c..77199595012a 100644 --- a/state/remote/s3.go +++ b/state/remote/s3.go @@ -26,19 +26,28 @@ func s3Factory(conf map[string]string) (Client, error) { if !ok { regionName = os.Getenv("AWS_DEFAULT_REGION") if regionName == "" { - return nil, fmt.Errorf("missing 'region' configuration or AWS_DEFAULT_REGION environment variable") + return nil, fmt.Errorf( + "missing 'region' configuration or AWS_DEFAULT_REGION environment variable") } } accessKeyId := conf["access_key"] secretAccessKey := conf["secret_key"] - credentialsProvider := credentials.NewStaticCredentials(accessKeyId, secretAccessKey, "") + credentialsProvider := credentials.NewChainCredentials([]credentials.Provider{ + &credentials.StaticProvider{Value: credentials.Value{ + AccessKeyID: accessKeyId, + SecretAccessKey: secretAccessKey, + SessionToken: "", + }}, + &credentials.EnvProvider{}, + }) // Make sure we got some sort of working credentials. _, err := credentialsProvider.Get() if err != nil { - return nil, fmt.Errorf("Unable to determine AWS credentials. Set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.\n(error was: %s)", err) + return nil, fmt.Errorf("Unable to determine AWS credentials. Set the AWS_ACCESS_KEY_ID and "+ + "AWS_SECRET_ACCESS_KEY environment variables.\n(error was: %s)", err) } awsConfig := &aws.Config{ From 897bf5e53d69cfc50748f664433fff35b8fd4eb6 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Tue, 5 May 2015 20:38:35 +0200 Subject: [PATCH 2/2] Added `SharedCredentialsProvider` and `EC2RoleProvider` as well... --- state/remote/s3.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/state/remote/s3.go b/state/remote/s3.go index 77199595012a..6db07d0704fa 100644 --- a/state/remote/s3.go +++ b/state/remote/s3.go @@ -41,6 +41,8 @@ func s3Factory(conf map[string]string) (Client, error) { SessionToken: "", }}, &credentials.EnvProvider{}, + &credentials.SharedCredentialsProvider{Filename: "", Profile: ""}, + &credentials.EC2RoleProvider{}, }) // Make sure we got some sort of working credentials.