From 9e66e18334afc3e9a4c8d4daf3241416468e58a8 Mon Sep 17 00:00:00 2001 From: Rafal Jeczalik Date: Sat, 21 Nov 2015 17:16:50 +0100 Subject: [PATCH] provider/aws: fix for https://github.com/aws/aws-sdk-go/issues/452 --- builtin/providers/aws/provider.go | 4 +++- state/remote/s3.go | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/provider.go b/builtin/providers/aws/provider.go index 91396ebbf..ba627d2ec 100644 --- a/builtin/providers/aws/provider.go +++ b/builtin/providers/aws/provider.go @@ -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() diff --git a/state/remote/s3.go b/state/remote/s3.go index 2285a54eb..28bb7b5f9 100644 --- a/state/remote/s3.go +++ b/state/remote/s3.go @@ -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.