From 00314fc3c35793c0f6c9611c7beb012fa0c1c037 Mon Sep 17 00:00:00 2001 From: Julien Sobczak Date: Tue, 16 Apr 2019 11:48:43 +0200 Subject: [PATCH] objstore: Expose S3 region attribute Minio is able to autodetect the region for cloud providers like AWS but the logic fails with Scaleway Object Storage solution. Related issue on Minio: https://github.com/minio/mc/issues/2570 --- CHANGELOG.md | 4 ++++ docs/storage.md | 7 ++++--- pkg/objstore/s3/s3.go | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c663993ed06..ef3ef2945ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ We use *breaking* word for marking changes that are not backward compatible (rel ## Unreleased +### Added + +- [#1060](https://github.com/improbable-eng/thanos/pull/1060) Expose S3 region attribute + ## [v0.4.0-rc.0](https://github.com/improbable-eng/thanos/releases/tag/v0.4.0-rc.0) - 2019.04.18 :warning: **IMPORTANT** :warning: This is the last release that supports gossip. From Thanos v0.5.0, gossip will be completely removed. diff --git a/docs/storage.md b/docs/storage.md index 1935d821f0b..62d15692e58 100644 --- a/docs/storage.md +++ b/docs/storage.md @@ -47,8 +47,9 @@ To configure S3 bucket as an object store you need to set these mandatory S3 var ```yaml type: S3 config: - bucket: "" - endpoint: "" + bucket: "" # required + endpoint: "" # required + region: "" # optional access_key: "" insecure: false signature_version2: false @@ -62,7 +63,7 @@ config: enable: false ``` -AWS region to endpoint mapping can be found in this [link](https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region) +AWS region to endpoint mapping can be found in this [link](https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region). Make sure you use a correct signature version. Currently AWS require signature v4, so it needs `signature-version2: false`, otherwise, you will get Access Denied error, but several other S3 compatible use `signature-version2: true` diff --git a/pkg/objstore/s3/s3.go b/pkg/objstore/s3/s3.go index c0fe3b98d98..115b6c4c20a 100644 --- a/pkg/objstore/s3/s3.go +++ b/pkg/objstore/s3/s3.go @@ -37,6 +37,7 @@ const DirDelim = "/" type Config struct { Bucket string `yaml:"bucket"` Endpoint string `yaml:"endpoint"` + Region string `yaml:"region"` AccessKey string `yaml:"access_key"` Insecure bool `yaml:"insecure"` SignatureV2 bool `yaml:"signature_version2"` @@ -122,7 +123,7 @@ func NewBucketWithConfig(logger log.Logger, config Config, component string) (*B } } - client, err := minio.NewWithCredentials(config.Endpoint, credentials.NewChainCredentials(chain), !config.Insecure, "") + client, err := minio.NewWithCredentials(config.Endpoint, credentials.NewChainCredentials(chain), !config.Insecure, config.Region) if err != nil { return nil, errors.Wrap(err, "initialize s3 client") }