Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding s3 endpoint #1

Merged
merged 3 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Note that if you specify more than one storage option, *all* options will be wri

`local_storage` - Object for writing to a file on disk.

`aws_storage` - Object for writing to an S3 bucket.
`aws_storage` - Object for writing to an S3 bucket (Support AWS S3 but also S3 Compatible Storage).

`google_storage` - Object for writing to GCS.

Expand All @@ -87,6 +87,10 @@ Note that if you specify more than one storage option, *all* options will be wri

`secret_access_key` - Recommended to use the standard `SECRET_ACCESS_KEY` env var, but its possible to specify this in the config

`s3_endpoint` - S3 compatible storage endpoint (ex: http://127.0.0.1:9000)

`s3_force_path_style` - Needed if your S3 Compatible storage support only path-style or you would like to use S3's FIPS Endpoint.

`s3_region` - S3 region as is required for programmatic interaction with AWS

`s3_bucket` - bucket to store snapshots in (required for AWS writes to work)
Expand Down
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ type S3Config struct {
Uploader *s3manager.Uploader
AccessKeyID string `json:"access_key_id"`
SecretAccessKey string `json:"secret_access_key"`
Endpoint string `json:"s3_endpoint"`
Region string `json:"s3_region"`
Bucket string `json:"s3_bucket"`
KeyPrefix string `json:"s3_key_prefix"`
SSE bool `json:"s3_server_side_encryption"`
StaticSnapshotName string `json:"s3_static_snapshot_name"`
S3ForcePathStyle bool `json:"s3_force_path_style"`
}

// ReadConfig reads the configuration file
Expand Down
8 changes: 8 additions & 0 deletions snapshot_agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ func (s *Snapshotter) ConfigureS3(config *config.Configuration) error {
awsConfig.Credentials = credentials.NewStaticCredentials(config.AWS.AccessKeyID, config.AWS.SecretAccessKey, "")
}

if config.AWS.Endpoint != "" {
awsConfig.Endpoint = aws.String(config.AWS.Endpoint)
}

if config.AWS.S3ForcePathStyle != false {
awsConfig.S3ForcePathStyle = aws.Bool(config.AWS.S3ForcePathStyle)
}

sess := session.Must(session.NewSession(awsConfig))
s.S3Client = s3.New(sess)
s.Uploader = s3manager.NewUploader(sess)
Expand Down
Binary file added vault_raft_snapshot_agent
Binary file not shown.