From d61cf9b4b26b0b7e4e68e9b11d2e47ab89f6363a Mon Sep 17 00:00:00 2001 From: Rafal Jeczalik Date: Sat, 21 Nov 2015 17:16:50 +0100 Subject: [PATCH] provider/aws: temporary fix for https://github.com/aws/aws-sdk-go/issues/452 --- builtin/providers/aws/provider.go | 7 ++++++- state/remote/s3.go | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/provider.go b/builtin/providers/aws/provider.go index f442f99303..712a3b4ed6 100644 --- a/builtin/providers/aws/provider.go +++ b/builtin/providers/aws/provider.go @@ -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 @@ -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() diff --git a/state/remote/s3.go b/state/remote/s3.go index 2285a54eba..a7e653f274 100644 --- a/state/remote/s3.go +++ b/state/remote/s3.go @@ -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 { @@ -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.