Skip to content

Commit

Permalink
s3: added optional --region parameter
Browse files Browse the repository at this point in the history
Fixes #168
  • Loading branch information
jkowalski committed Jan 10, 2020
1 parent 0b8c4d0 commit 644ef93
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions cli/storage_s3.go
Expand Up @@ -18,6 +18,7 @@ func init() {
func(cmd *kingpin.CmdClause) {
cmd.Flag("bucket", "Name of the S3 bucket").Required().StringVar(&s3options.BucketName)
cmd.Flag("endpoint", "Endpoint to use").Default("s3.amazonaws.com").StringVar(&s3options.Endpoint)
cmd.Flag("region", "S3 Region").Default("").StringVar(&s3options.Region)
cmd.Flag("access-key", "Access key ID (overrides AWS_ACCESS_KEY_ID environment variable)").Required().Envar("AWS_ACCESS_KEY_ID").StringVar(&s3options.AccessKeyID)
cmd.Flag("secret-access-key", "Secret access key (overrides AWS_SECRET_ACCESS_KEY environment variable)").Required().Envar("AWS_SECRET_ACCESS_KEY").StringVar(&s3options.SecretAccessKey)
cmd.Flag("prefix", "Prefix to use for objects in the bucket").StringVar(&s3options.Prefix)
Expand Down
3 changes: 3 additions & 0 deletions repo/blob/s3/s3_options.go
Expand Up @@ -14,6 +14,9 @@ type Options struct {
AccessKeyID string `json:"accessKeyID"`
SecretAccessKey string `json:"secretAccessKey" kopia:"sensitive"`

// Region is an optional region to pass in authorization header.
Region string `json:"region,omitempty"`

MaxUploadSpeedBytesPerSecond int `json:"maxUploadSpeedBytesPerSecond,omitempty"`

MaxDownloadSpeedBytesPerSecond int `json:"maxDownloadSpeedBytesPerSecond,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion repo/blob/s3/s3_storage.go
Expand Up @@ -224,7 +224,7 @@ func New(ctx context.Context, opt *Options) (blob.Storage, error) {
return nil, errors.New("bucket name must be specified")
}

cli, err := minio.New(opt.Endpoint, opt.AccessKeyID, opt.SecretAccessKey, !opt.DoNotUseTLS)
cli, err := minio.NewWithRegion(opt.Endpoint, opt.AccessKeyID, opt.SecretAccessKey, !opt.DoNotUseTLS, opt.Region)
if err != nil {
return nil, errors.Wrap(err, "unable to create client")
}
Expand Down

0 comments on commit 644ef93

Please sign in to comment.