mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
tiered storage: add s3 endpoint for private s3 implementation
fix https://github.com/chrislusf/seaweedfs/issues/1238
This commit is contained in:
parent
d848d08944
commit
709f231e23
|
@ -380,6 +380,7 @@ sequencer_etcd_urls = "http://127.0.0.1:2379"
|
|||
aws_secret_access_key = "" # if empty, loads from the shared credentials file (~/.aws/credentials).
|
||||
region = "us-east-2"
|
||||
bucket = "your_bucket_name" # an existing bucket
|
||||
endpoint = ""
|
||||
|
||||
# create this number of logical volumes if no more writable volumes
|
||||
# count_x means how many copies of data.
|
||||
|
|
|
@ -36,6 +36,7 @@ type S3BackendStorage struct {
|
|||
aws_secret_access_key string
|
||||
region string
|
||||
bucket string
|
||||
endpoint string
|
||||
conn s3iface.S3API
|
||||
}
|
||||
|
||||
|
@ -46,7 +47,9 @@ func newS3BackendStorage(configuration backend.StringProperties, configPrefix st
|
|||
s.aws_secret_access_key = configuration.GetString(configPrefix + "aws_secret_access_key")
|
||||
s.region = configuration.GetString(configPrefix + "region")
|
||||
s.bucket = configuration.GetString(configPrefix + "bucket")
|
||||
s.conn, err = createSession(s.aws_access_key_id, s.aws_secret_access_key, s.region)
|
||||
s.endpoint = configuration.GetString(configPrefix + "endpoint")
|
||||
|
||||
s.conn, err = createSession(s.aws_access_key_id, s.aws_secret_access_key, s.region, s.endpoint)
|
||||
|
||||
glog.V(0).Infof("created backend storage s3.%s for region %s bucket %s", s.id, s.region, s.bucket)
|
||||
return
|
||||
|
@ -58,6 +61,7 @@ func (s *S3BackendStorage) ToProperties() map[string]string {
|
|||
m["aws_secret_access_key"] = s.aws_secret_access_key
|
||||
m["region"] = s.region
|
||||
m["bucket"] = s.bucket
|
||||
m["endpoint"] = s.endpoint
|
||||
return m
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ func getSession(region string) (s3iface.S3API, bool) {
|
|||
return sess, found
|
||||
}
|
||||
|
||||
func createSession(awsAccessKeyId, awsSecretAccessKey, region string) (s3iface.S3API, error) {
|
||||
func createSession(awsAccessKeyId, awsSecretAccessKey, region, endpoint string) (s3iface.S3API, error) {
|
||||
|
||||
sessionsLock.Lock()
|
||||
defer sessionsLock.Unlock()
|
||||
|
@ -34,7 +34,8 @@ func createSession(awsAccessKeyId, awsSecretAccessKey, region string) (s3iface.S
|
|||
}
|
||||
|
||||
config := &aws.Config{
|
||||
Region: aws.String(region),
|
||||
Region: aws.String(region),
|
||||
Endpoint: aws.String(endpoint),
|
||||
}
|
||||
if awsAccessKeyId != "" && awsSecretAccessKey != "" {
|
||||
config.Credentials = credentials.NewStaticCredentials(awsAccessKeyId, awsSecretAccessKey, "")
|
||||
|
|
Loading…
Reference in a new issue