Skip to content

Commit

Permalink
Allow S3 buckets in different regions, implements #2007
Browse files Browse the repository at this point in the history
This commit allows additional configuration
for the `audit_sessions_uri` parameter:

`audit_sessions_uri: s3://example.com/path?region=us-east-1`

Additional query parameter `region` will override
default `audit` section `region` if set.
  • Loading branch information
klizhentas committed Feb 9, 2019
1 parent 7621bbd commit cf7766b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ const (
// storage
SchemeS3 = "s3"

// Region is AWS region parameter
Region = "region"

// SchemeFile is a local disk file storage
SchemeFile = "file"

Expand Down
2 changes: 1 addition & 1 deletion lib/events/s3sessions/s3handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func NewHandler(cfg Config) (*Handler, error) {
client: s3.New(cfg.Session),
}
start := time.Now()
h.Infof("Setting up bucket %q.", h.Bucket)
h.Infof("Setting up bucket %q, sessions path %q in region %q.", h.Bucket, h.Path, h.Region)
if err := h.ensureBucket(); err != nil {
return nil, trace.Wrap(err)
}
Expand Down
6 changes: 5 additions & 1 deletion lib/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,13 @@ func initUploadHandler(auditConfig services.AuditConfig) (events.UploadHandler,

switch uri.Scheme {
case teleport.SchemeS3:
region := auditConfig.Region
if uriRegion := uri.Query().Get(teleport.Region); uriRegion != "" {
region = uriRegion
}
handler, err := s3sessions.NewHandler(s3sessions.Config{
Bucket: uri.Host,
Region: auditConfig.Region,
Region: region,
Path: uri.Path,
})
if err != nil {
Expand Down

0 comments on commit cf7766b

Please sign in to comment.