Merge pull request #4024 from rjeczalik/nil-deref-fix

provider/aws: fix for https://github.com/aws/aws-sdk-go/issues/452
This commit is contained in:
James Nugent 2015-11-24 11:52:33 +02:00
commit 288e568272
2 changed files with 5 additions and 2 deletions

View File

@ -12,6 +12,8 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds"
"github.com/aws/aws-sdk-go/aws/ec2metadata"
"github.com/aws/aws-sdk-go/aws/session"
)
// Provider returns a terraform.ResourceProvider.
@ -42,7 +44,7 @@ func Provider() terraform.ResourceProvider {
conn, err := net.DialTimeout("tcp", "169.254.169.254:80", 100*time.Millisecond)
if err == nil {
conn.Close()
providers = append(providers, &ec2rolecreds.EC2RoleProvider{})
providers = append(providers, &ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(session.New())})
}
credVal, credErr = credentials.NewChainCredentials(providers).Get()

View File

@ -12,6 +12,7 @@ import (
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds"
"github.com/aws/aws-sdk-go/aws/ec2metadata"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/hashicorp/go-cleanhttp"
@ -64,7 +65,7 @@ func s3Factory(conf map[string]string) (Client, error) {
}},
&credentials.EnvProvider{},
&credentials.SharedCredentialsProvider{Filename: "", Profile: ""},
&ec2rolecreds.EC2RoleProvider{},
&ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(session.New())},
})
// Make sure we got some sort of working credentials.