Skip to content

Commit

Permalink
Support custom endpoint for S3 (grafana#1476)
Browse files Browse the repository at this point in the history
Signed-off-by: mizeng <[email protected]>
  • Loading branch information
mizeng authored and csmarchbanks committed Jun 28, 2019
1 parent 7e84a55 commit 4f9d36a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion aws/dynamodb_storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ func (cfg *DynamoDBConfig) RegisterFlags(f *flag.FlagSet) {
// StorageConfig specifies config for storing data on AWS.
type StorageConfig struct {
DynamoDBConfig
S3 flagext.URLValue
S3 flagext.URLValue
S3ForcePathStyle bool
}

// RegisterFlags adds the flags required to config this to the given FlagSet
Expand All @@ -135,6 +136,7 @@ func (cfg *StorageConfig) RegisterFlags(f *flag.FlagSet) {

f.Var(&cfg.S3, "s3.url", "S3 endpoint URL with escaped Key and Secret encoded. "+
"If only region is specified as a host, proper endpoint will be deduced. Use inmemory:///<bucket-name> to use a mock in-memory implementation.")
f.BoolVar(&cfg.S3ForcePathStyle, "s3.force-path-style", false, "Set this to `true` to force the request to use path-style addressing.")
}

type dynamoDBStorageClient struct {
Expand Down
2 changes: 2 additions & 0 deletions aws/s3_storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func NewS3ObjectClient(cfg StorageConfig, schemaCfg chunk.SchemaConfig) (chunk.O
return nil, err
}

s3Config = s3Config.WithS3ForcePathStyle(cfg.S3ForcePathStyle) // support for Path Style S3 url if has the flag

s3Config = s3Config.WithMaxRetries(0) // We do our own retries, so we can monitor them
s3Client := s3.New(session.New(s3Config))
bucketName := strings.TrimPrefix(cfg.S3.URL.Path, "/")
Expand Down

0 comments on commit 4f9d36a

Please sign in to comment.