Skip to content

Commit 0dbaea5

Browse files
committed
Add support for AWS shared credentials file
Signed-off-by: Brad Davidson <[email protected]>
1 parent d0ea741 commit 0dbaea5

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

pkg/etcd/s3/s3.go

+10-8
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,16 @@ func (c *Controller) GetClient(ctx context.Context, etcdS3 *config.EtcdS3) (*Cli
199199
tr.Proxy = http.ProxyURL(u)
200200
}
201201

202-
var creds *credentials.Credentials
203-
if len(etcdS3.AccessKey) == 0 && len(etcdS3.SecretKey) == 0 {
204-
creds = credentials.NewIAM("") // for running on ec2 instance
205-
if _, err := creds.Get(); err != nil {
206-
return nil, errors.Wrap(err, "failed to get IAM credentials")
207-
}
208-
} else {
209-
creds = credentials.NewStaticV4(etcdS3.AccessKey, etcdS3.SecretKey, "")
202+
creds := credentials.NewChainCredentials([]credentials.Provider{
203+
credentials.NewStaticV4(etcdS3.AccessKey, etcdS3.SecretKey, ""),
204+
credentials.NewFileAWSCredentials("", ""),
205+
credentials.NewIAM(""),
206+
})
207+
208+
if cval, err := creds.Get(); err != nil {
209+
return nil, errors.Wrap(err, "failed to get credentials")
210+
} else if cval.SignerType == credentials.SignatureAnonymous {
211+
return nil, errors.New("all credential providers failed; cannot use anonymous")
210212
}
211213

212214
opt := minio.Options{

0 commit comments

Comments
 (0)