From 9a91ae4e8fb3510c4c2e275a5aa2741b0c36bb65 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Mon, 14 Nov 2016 11:39:22 -0800 Subject: [PATCH] fix new session error when creating cred chain. the old and deprecated method won't error and so is safe to use even if we're not in amazon. --- builder/amazon/common/access_config.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/builder/amazon/common/access_config.go b/builder/amazon/common/access_config.go index 3d1c73a6f..046631755 100644 --- a/builder/amazon/common/access_config.go +++ b/builder/amazon/common/access_config.go @@ -45,10 +45,6 @@ func (c *AccessConfig) Config() (*aws.Config, error) { return nil, err } } else { - session, err := session.NewSession(config) - if err != nil { - return nil, err - } creds = credentials.NewChainCredentials([]credentials.Provider{ &credentials.StaticProvider{Value: credentials.Value{ AccessKeyID: c.AccessKey, @@ -58,7 +54,7 @@ func (c *AccessConfig) Config() (*aws.Config, error) { &credentials.EnvProvider{}, &credentials.SharedCredentialsProvider{Filename: "", Profile: ""}, &ec2rolecreds.EC2RoleProvider{ - Client: ec2metadata.New(session), + Client: ec2metadata.New(session.New(config)), }, }) }