Allow using ec2 roles when specifying region endpoint

Signed-off-by: Lloyd Ramey <lnr0626@gmail.com>
This commit is contained in:
Lloyd Ramey 2016-10-13 18:07:37 -04:00
parent 252cc27ab1
commit c8ea7840d3

View file

@ -389,9 +389,7 @@ func New(params DriverParameters) (*Driver, error) {
} }
awsConfig := aws.NewConfig() awsConfig := aws.NewConfig()
var creds *credentials.Credentials creds := credentials.NewChainCredentials([]credentials.Provider{
if params.RegionEndpoint == "" {
creds = credentials.NewChainCredentials([]credentials.Provider{
&credentials.StaticProvider{ &credentials.StaticProvider{
Value: credentials.Value{ Value: credentials.Value{
AccessKeyID: params.AccessKey, AccessKeyID: params.AccessKey,
@ -402,16 +400,8 @@ func New(params DriverParameters) (*Driver, error) {
&credentials.SharedCredentialsProvider{}, &credentials.SharedCredentialsProvider{},
&ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(session.New())}, &ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(session.New())},
}) })
} else {
creds = credentials.NewChainCredentials([]credentials.Provider{ if params.RegionEndpoint != "" {
&credentials.StaticProvider{
Value: credentials.Value{
AccessKeyID: params.AccessKey,
SecretAccessKey: params.SecretKey,
},
},
&credentials.EnvProvider{},
})
awsConfig.WithS3ForcePathStyle(true) awsConfig.WithS3ForcePathStyle(true)
awsConfig.WithEndpoint(params.RegionEndpoint) awsConfig.WithEndpoint(params.RegionEndpoint)
} }