88require "thread"
99require "tmpdir"
1010require "fileutils"
11+ require "uri"
1112
1213
1314# INFORMATION:
5960# This is an example of logstash config:
6061# [source,ruby]
6162# output {
62- # s3{
63+ # s3 {
6364# access_key_id => "crazy_key" (required)
6465# secret_access_key => "monkey_access_key" (required)
66+ # endpoint => "http://127.0.0.1:8080" (optional, used for non-AWS endpoints, default = "")
6567# region => "eu-west-1" (optional, default = "us-east-1")
6668# bucket => "boss_please_open_your_bucket" (required)
6769# size_file => 2048 (optional) - Bytes
@@ -82,6 +84,9 @@ class LogStash::Outputs::S3 < LogStash::Outputs::Base
8284 # S3 bucket
8385 config :bucket , :validate => :string
8486
87+ # endpoint
88+ config :endpoint , :validate => :string
89+
8590 # Set the size of file in bytes, this means that files on bucket when have dimension > file_size, they are stored in two or more file.
8691 # If you have tags then it will generate a specific size file for every tags
8792 ##NOTE: define size of file is the better thing, because generate a local temporary file on disk and then put it in bucket.
@@ -145,6 +150,7 @@ def aws_s3_config
145150
146151 def full_options
147152 aws_options_hash . merge ( signature_options )
153+ aws_options_hash . merge ( endpoint_options )
148154 end
149155
150156 def signature_options
@@ -155,6 +161,20 @@ def signature_options
155161 end
156162 end
157163
164+ def endpoint_options
165+ if @endpoint
166+ uri = URI ( @endpoint )
167+ {
168+ :s3_force_path_style => true ,
169+ :s3_endpoint => uri . host ,
170+ :s3_port => uri . port ,
171+ :use_ssl => uri . scheme == "https" ,
172+ }
173+ else
174+ { }
175+ end
176+ end
177+
158178 def aws_service_endpoint ( region )
159179 return {
160180 :s3_endpoint => region == 'us-east-1' ? 's3.amazonaws.com' : "s3-#{ region } .amazonaws.com"
0 commit comments