8
8
require "thread"
9
9
require "tmpdir"
10
10
require "fileutils"
11
+ require "uri"
11
12
12
13
13
14
# INFORMATION:
59
60
# This is an example of logstash config:
60
61
# [source,ruby]
61
62
# output {
62
- # s3{
63
+ # s3 {
63
64
# access_key_id => "crazy_key" (required)
64
65
# secret_access_key => "monkey_access_key" (required)
66
+ # endpoint => "http://127.0.0.1:8080" (optional, used for non-AWS endpoints, default = "")
65
67
# region => "eu-west-1" (optional, default = "us-east-1")
66
68
# bucket => "boss_please_open_your_bucket" (required)
67
69
# size_file => 2048 (optional) - Bytes
@@ -84,6 +86,9 @@ class LogStash::Outputs::S3 < LogStash::Outputs::Base
84
86
# S3 bucket
85
87
config :bucket , :validate => :string
86
88
89
+ # endpoint
90
+ config :endpoint , :validate => :string
91
+
87
92
# 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.
88
93
# If you have tags then it will generate a specific size file for every tags
89
94
##NOTE: define size of file is the better thing, because generate a local temporary file on disk and then put it in bucket.
@@ -147,6 +152,7 @@ def aws_s3_config
147
152
148
153
def full_options
149
154
aws_options_hash . merge ( signature_options )
155
+ aws_options_hash . merge ( endpoint_options )
150
156
end
151
157
152
158
def signature_options
@@ -157,6 +163,20 @@ def signature_options
157
163
end
158
164
end
159
165
166
+ def endpoint_options
167
+ if @endpoint
168
+ uri = URI ( @endpoint )
169
+ {
170
+ :s3_force_path_style => true ,
171
+ :s3_endpoint => uri . host ,
172
+ :s3_port => uri . port ,
173
+ :use_ssl => uri . scheme == "https" ,
174
+ }
175
+ else
176
+ { }
177
+ end
178
+ end
179
+
160
180
def aws_service_endpoint ( region )
161
181
return {
162
182
:s3_endpoint => region == 'us-east-1' ? 's3.amazonaws.com' : "s3-#{ region } .amazonaws.com"
0 commit comments