Skip to content

Commit

Permalink
connector: customendpoint flag for NewAWSReader
Browse files Browse the repository at this point in the history
Workaround to use min.io or other compatible service as s3 backend
Using custom region as flag to indicate that we are not using
aws services.
  • Loading branch information
talset committed May 4, 2020
1 parent c86b87c commit 926ab40
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,32 @@ func NewAWSReader(
ctx context.Context, accessKey string, secretKey string, regions []string, config *aws.Config,
) (AWSReader, error) {
var c = connector{}
const customEndpointRegion string = "custom"

creds, ec2s, sts, err := configureAWS(accessKey, secretKey)
if err != nil {
return nil, err
}
c.creds = creds
if err := c.setAccountID(ctx, sts); err != nil {
return nil, err

// Workaround to use with min.io as s3 backend
// Using custom region as flag to indicate that we are not using aws services.
customEndpoint := false
for _, region := range regions {
if region == customEndpointRegion {
customEndpoint = true
break
}
}
if err := c.setRegions(ctx, ec2s, regions); err != nil {
return nil, err
if customEndpoint {
c.regions = regions
} else {
if err := c.setAccountID(ctx, sts); err != nil {
return nil, err
}
if err := c.setRegions(ctx, ec2s, regions); err != nil {
return nil, err
}
}
c.setServices(config)
return &c, nil
Expand Down

0 comments on commit 926ab40

Please sign in to comment.