Skip to content

Commit

Permalink
provider/aws: fix for aws/aws-sdk-go#452
Browse files Browse the repository at this point in the history
  • Loading branch information
rjeczalik committed Nov 23, 2015
1 parent 5024d66 commit efaaa0a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion builtin/providers/aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"

"github.com/aws/aws-sdk-go/aws"
"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"
)

var defaultClient = ec2metadata.New(session.New(aws.NewConfig()))

// Provider returns a terraform.ResourceProvider.
func Provider() terraform.ResourceProvider {
// TODO: Move the validation to this, requires conditional schemas
Expand Down Expand Up @@ -42,7 +47,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: defaultClient})
}

credVal, credErr = credentials.NewChainCredentials(providers).Get()
Expand Down
5 changes: 4 additions & 1 deletion state/remote/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ 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"
)

var defaultClient = ec2metadata.New(session.New(aws.NewConfig()))

func s3Factory(conf map[string]string) (Client, error) {
bucketName, ok := conf["bucket"]
if !ok {
Expand Down Expand Up @@ -64,7 +67,7 @@ func s3Factory(conf map[string]string) (Client, error) {
}},
&credentials.EnvProvider{},
&credentials.SharedCredentialsProvider{Filename: "", Profile: ""},
&ec2rolecreds.EC2RoleProvider{},
&ec2rolecreds.EC2RoleProvider{Client: defaultClient},
})

// Make sure we got some sort of working credentials.
Expand Down

0 comments on commit efaaa0a

Please sign in to comment.