diff --git a/builder/amazon/common/access_config.go b/builder/amazon/common/access_config.go index a10fc52f3..d1f5b6ffb 100644 --- a/builder/amazon/common/access_config.go +++ b/builder/amazon/common/access_config.go @@ -10,6 +10,8 @@ import ( "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" "github.com/mitchellh/packer/template/interpolate" ) @@ -42,6 +44,7 @@ func (c *AccessConfig) Config() (*aws.Config, error) { return nil, err } } else { + sess := session.New(config) creds = credentials.NewChainCredentials([]credentials.Provider{ &credentials.StaticProvider{Value: credentials.Value{ AccessKeyID: c.AccessKey, @@ -50,7 +53,9 @@ func (c *AccessConfig) Config() (*aws.Config, error) { }}, &credentials.EnvProvider{}, &credentials.SharedCredentialsProvider{Filename: "", Profile: ""}, - &ec2rolecreds.EC2RoleProvider{}, + &ec2rolecreds.EC2RoleProvider{ + Client: ec2metadata.New(sess), + }, }) } return config.WithCredentials(creds), nil