fluent-plugin-s3 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7857c3b94c15cb4823304fee564472f765550dd22e31d45573275c4db78124f1
4
- data.tar.gz: 77ebe69806ddc016fb49a01affe134f16c8eb62201b15cce69d20aeaacd17d59
3
+ metadata.gz: 01721ed2077803f70f07f527930897219b5572c9e316f9b558cd225182562971
4
+ data.tar.gz: 3c7868ecd16e92e3430f3ea8c1a585f8ed1cfc7dc22ecc6c6cfe1d75c3f36a9e
5
5
  SHA512:
6
- metadata.gz: a0d66bbd627a801c39fe4da90135dc4c4b457c522de73c9d14e03786a3dd0b5b8cb2c51d2eb11c8fd615897626fdf9c6d689cbae4be2842d75b5b2846426ab4b
7
- data.tar.gz: 8500765a686f41f5ed76c9738fd8466dd64cdda9ca840b5fef0b618d7a9bf0da6d8ba8a46fc239893964ddf9bddd7dcfa54cc71587a69fb4b5417f2592d2cc1c
6
+ metadata.gz: d56e3bd45a7813319ccc63cee70cf664989e832151a0d1f8757b4329ff96405e39211e1dfe14a51cb2523274ab9bdf6e2d087b8ba4e4c3fa790d963986f7f5f0
7
+ data.tar.gz: b06b219b31ef293b15c200d5824f34600a15075626f6ac3591e54ce3ceb7b214fa0c90fc4b683629a3b6c9de2a5fc1f93a6be93a038f9acf301db14b8bb96e2c
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Release 1.3.0 - 2020/02/10
2
+
3
+ * in_s3/out_s3: Support AssumeRoleWebIdentityCredentials via `web_identity_credentials` section for EKS.
4
+
1
5
  Release 1.2.1 - 2019/11/10
2
6
 
3
7
  * in_s3: Support ECSCredentials
data/README.md CHANGED
@@ -93,6 +93,51 @@ is set to 3600 seconds.
93
93
  A unique identifier that is used by third parties when assuming roles in
94
94
  their customers' accounts.
95
95
 
96
+ ### web_identity_credentials
97
+
98
+ Similar to the assume_role_credentials, but for usage in EKS.
99
+
100
+ <match *>
101
+ @type s3
102
+
103
+ <web_identity_credentials>
104
+ role_arn ROLE_ARN
105
+ role_session_name ROLE_SESSION_NAME
106
+ web_identity_token_file AWS_WEB_IDENTITY_TOKEN_FILE
107
+ </web_identity_credentials>
108
+ </match>
109
+
110
+ See also:
111
+
112
+ * [Using IAM Roles - AWS Identity and Access
113
+ Management](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html)
114
+ * [IAM Roles For Service Accounts](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts-technical-overview.html)
115
+ * [Aws::STS::Client](http://docs.aws.amazon.com/sdkforruby/api/Aws/STS/Client.html)
116
+ * [Aws::AssumeRoleWebIdentityCredentials](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/AssumeRoleWebIdentityCredentials.html)
117
+
118
+ **role_arn (required)**
119
+
120
+ The Amazon Resource Name (ARN) of the role to assume.
121
+
122
+ **role_session_name (required)**
123
+
124
+ An identifier for the assumed role session.
125
+
126
+ **web_identity_token_file (required)**
127
+
128
+ The absolute path to the file on disk containing the OIDC token
129
+
130
+ **policy**
131
+
132
+ An IAM policy in JSON format.
133
+
134
+ **duration_seconds**
135
+
136
+ The duration, in seconds, of the role session. The value can range from
137
+ 900 seconds (15 minutes) to 43200 seconds (12 hours). By default, the value
138
+ is set to 3600 seconds.
139
+
140
+
96
141
  ### instance_profile_credentials
97
142
 
98
143
  Retrieve temporary security credentials via HTTP request. This is useful on
@@ -165,7 +210,7 @@ Defaults to 'default' or `[ENV]('AWS_PROFILE')`.
165
210
 
166
211
  ### v1.0 style
167
212
 
168
- With fluentd v1.0 and fluent-plugin-s3 v1.0.0, use new buffer configuration to dynamic parameters.
213
+ With fluentd v1 and fluent-plugin-s3 v1.0.0 or later, use new buffer configuration to dynamic parameters.
169
214
 
170
215
  <match pattern>
171
216
  @type s3
@@ -248,7 +293,9 @@ recommend using `s3_region` instead of `s3_endpoint`.
248
293
  **s3_endpoint**
249
294
 
250
295
  endpoint for S3 compatible services. For example, Riak CS based storage or
251
- something. This option doesn't work on S3, use `s3_region` instead.
296
+ something. This option is deprecated for AWS S3, use `s3_region` instead.
297
+
298
+ See also AWS article: [Working with Regions](https://aws.amazon.com/blogs/developer/working-with-regions/).
252
299
 
253
300
  **enable_transfer_acceleration**
254
301
 
@@ -297,6 +344,13 @@ You can configure the length of string with a
297
344
  `hex_random_length` parameter (Default: 4).
298
345
 
299
346
  The default format is `%{path}%{time_slice}_%{index}.%{file_extension}`.
347
+ In addition, you can use [buffer placeholders](https://docs.fluentd.org/configuration/buffer-section#placeholders) in this parameter,
348
+ so you can embed tag, time and record value like below:
349
+
350
+ s3_object_key_format %{path}/events/%Y%m%d/${tag}_%{index}.%{file_extension}
351
+ <buffer tag,time>
352
+ # buffer parameters...
353
+ </buffer>
300
354
 
301
355
  For instance, using the example configuration above, actual object keys on S3
302
356
  will be something like:
@@ -352,7 +406,7 @@ See `Use your compression algorithm` section for adding another format.
352
406
  **`<format>` or format**
353
407
 
354
408
  Change one line format in the S3 object. Supported formats are "out_file",
355
- "json", "ltsv" and "single_value". See also [official Formatter article](https://docs.fluentd.org/formatter).
409
+ "json", "ltsv", "single_value" and other formatter plugins. See also [official Formatter article](https://docs.fluentd.org/formatter).
356
410
 
357
411
  * out_file (default).
358
412
 
@@ -372,7 +426,14 @@ information to the record by setting "include_tag_key" / "tag_key" and
372
426
  "include_time_key" / "time_key" option. If you set following configuration in
373
427
  S3 output:
374
428
 
375
- format json
429
+ # v1
430
+ <format>
431
+ @type json
432
+ include_time_key true
433
+ time_key log_time # default is time
434
+ </format>
435
+ # v0.12
436
+ @format json
376
437
  include_time_key true
377
438
  time_key log_time # default is time
378
439
 
@@ -431,21 +492,34 @@ uri of proxy environment.
431
492
  **path**
432
493
 
433
494
  path prefix of the files on S3. Default is "" (no prefix).
495
+ [buffer placeholder](https://docs.fluentd.org/configuration/buffer-section#placeholders) is supported,
496
+ so you can embed tag, time and record value like below.
434
497
 
435
- **buffer_path (required)**
498
+ path logs/%Y%m%d/${tag}/
499
+ <buffer tag,time>
500
+ # buffer parameters...
501
+ </buffer>
502
+
503
+ **buffer_path (for v0.12)**
436
504
 
437
505
  path prefix of the files to buffer logs.
438
506
 
439
- **time_slice_format**
507
+ This parameter is for v0.12. Use `<buffer>`'s `path` in v1.
508
+
509
+ **time_slice_format(for v0.12)**
440
510
 
441
511
  Format of the time used as the file name. Default is '%Y%m%d'. Use
442
512
  '%Y%m%d%H' to split files hourly.
443
513
 
444
- **time_slice_wait**
514
+ This parameter is for v0.12. Use buffer placeholder for `path` / `s3_object_key_format` in v1.
515
+
516
+ **time_slice_wait(for v0.12)**
445
517
 
446
518
  The time to wait old logs. Default is 10 minutes. Specify larger value if
447
519
  old logs may reach.
448
520
 
521
+ This parameter is for v0.12. Use `<buffer>`'s `timekey_wait` in v1.
522
+
449
523
  **utc**
450
524
 
451
525
  Use UTC instead of local time.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.1
1
+ 1.3.0
@@ -17,8 +17,8 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ['lib']
18
18
 
19
19
  gem.add_dependency "fluentd", [">= 0.14.22", "< 2"]
20
- gem.add_dependency "aws-sdk-s3", "~> 1.0"
21
- gem.add_dependency "aws-sdk-sqs", "~> 1.0"
20
+ gem.add_dependency "aws-sdk-s3", "~> 1.60"
21
+ gem.add_dependency "aws-sdk-sqs", "~> 1.23"
22
22
  gem.add_development_dependency "rake", ">= 0.9.2"
23
23
  gem.add_development_dependency "test-unit", ">= 3.0.8"
24
24
  gem.add_development_dependency "test-unit-rr", ">= 1.0.3"
@@ -42,6 +42,20 @@ module Fluent::Plugin
42
42
  desc "A unique identifier that is used by third parties when assuming roles in their customers' accounts."
43
43
  config_param :external_id, :string, default: nil
44
44
  end
45
+ # See the following link for additional params that could be added:
46
+ # https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/STS/Client.html#assume_role_with_web_identity-instance_method
47
+ config_section :web_identity_credentials, multi: false do
48
+ desc "The Amazon Resource Name (ARN) of the role to assume"
49
+ config_param :role_arn, :string # required
50
+ desc "An identifier for the assumed role session"
51
+ config_param :role_session_name, :string #required
52
+ desc "The absolute path to the file on disk containing the OIDC token"
53
+ config_param :web_identity_token_file, :string #required
54
+ desc "An IAM policy in JSON format"
55
+ config_param :policy, :string, default: nil
56
+ desc "The duration, in seconds, of the role session (900-43200)"
57
+ config_param :duration_seconds, :integer, default: nil
58
+ end
45
59
  config_section :instance_profile_credentials, multi: false do
46
60
  desc "Number of times to retry when retrieving credentials"
47
61
  config_param :retries, :integer, default: nil
@@ -202,6 +216,17 @@ module Fluent::Plugin
202
216
  credentials_options[:client] = Aws::STS::Client.new(:region => @s3_region)
203
217
  end
204
218
  options[:credentials] = Aws::AssumeRoleCredentials.new(credentials_options)
219
+ when @web_identity_credentials
220
+ c = @web_identity_credentials
221
+ credentials_options[:role_arn] = c.role_arn
222
+ credentials_options[:role_session_name] = c.role_session_name
223
+ credentials_options[:web_identity_token_file] = c.web_identity_token_file
224
+ credentials_options[:policy] = c.policy if c.policy
225
+ credentials_options[:duration_seconds] = c.duration_seconds if c.duration_seconds
226
+ if @s3_region
227
+ credentials_options[:client] = Aws::STS::Client.new(:region => @s3_region)
228
+ end
229
+ options[:credentials] = Aws::AssumeRoleWebIdentityCredentials.new(credentials_options)
205
230
  when @instance_profile_credentials
206
231
  c = @instance_profile_credentials
207
232
  credentials_options[:retries] = c.retries if c.retries
@@ -40,6 +40,20 @@ module Fluent::Plugin
40
40
  desc "A unique identifier that is used by third parties when assuming roles in their customers' accounts."
41
41
  config_param :external_id, :string, default: nil, secret: true
42
42
  end
43
+ # See the following link for additional params that could be added:
44
+ # https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/STS/Client.html#assume_role_with_web_identity-instance_method
45
+ config_section :web_identity_credentials, multi: false do
46
+ desc "The Amazon Resource Name (ARN) of the role to assume"
47
+ config_param :role_arn, :string # required
48
+ desc "An identifier for the assumed role session"
49
+ config_param :role_session_name, :string #required
50
+ desc "The absolute path to the file on disk containing the OIDC token"
51
+ config_param :web_identity_token_file, :string #required
52
+ desc "An IAM policy in JSON format"
53
+ config_param :policy, :string, default: nil
54
+ desc "The duration, in seconds, of the role session (900-43200)"
55
+ config_param :duration_seconds, :integer, default: nil
56
+ end
43
57
  config_section :instance_profile_credentials, multi: false do
44
58
  desc "Number of times to retry when retrieving credentials"
45
59
  config_param :retries, :integer, default: nil
@@ -175,7 +189,7 @@ module Fluent::Plugin
175
189
  end
176
190
 
177
191
  unless @index_format =~ /^%(0\d*)?[dxX]$/
178
- raise Fluent::ConfigError, "index_format parameter should follow `%[flags][width]type`. `0` is the only supported flag, and is mandatory if width is specified. `d`, `x` and `X` are supported types"
192
+ raise Fluent::ConfigError, "index_format parameter should follow `%[flags][width]type`. `0` is the only supported flag, and is mandatory if width is specified. `d`, `x` and `X` are supported types"
179
193
  end
180
194
 
181
195
  if @reduced_redundancy
@@ -460,6 +474,17 @@ module Fluent::Plugin
460
474
  credentials_options[:client] = Aws::STS::Client.new(region: @s3_region)
461
475
  end
462
476
  options[:credentials] = Aws::AssumeRoleCredentials.new(credentials_options)
477
+ when @web_identity_credentials
478
+ c = @web_identity_credentials
479
+ credentials_options[:role_arn] = c.role_arn
480
+ credentials_options[:role_session_name] = c.role_session_name
481
+ credentials_options[:web_identity_token_file] = c.web_identity_token_file
482
+ credentials_options[:policy] = c.policy if c.policy
483
+ credentials_options[:duration_seconds] = c.duration_seconds if c.duration_seconds
484
+ if @s3_region
485
+ credentials_options[:client] = Aws::STS::Client.new(:region => @s3_region)
486
+ end
487
+ options[:credentials] = Aws::AssumeRoleWebIdentityCredentials.new(credentials_options)
463
488
  when @instance_profile_credentials
464
489
  c = @instance_profile_credentials
465
490
  credentials_options[:retries] = c.retries if c.retries
data/test/test_in_s3.rb CHANGED
@@ -11,6 +11,7 @@ require 'fluent/plugin/in_s3'
11
11
  require 'test/unit/rr'
12
12
  require 'zlib'
13
13
  require 'fileutils'
14
+ require 'ostruct'
14
15
 
15
16
  include Fluent::Test::Helpers
16
17
 
@@ -152,6 +153,7 @@ EOS
152
153
 
153
154
  def setup_mocks
154
155
  @s3_client = stub(Aws::S3::Client.new(stub_responses: true))
156
+ stub(@s3_client).config { OpenStruct.new({region: "us-east-1"}) }
155
157
  mock(Aws::S3::Client).new(anything).at_least(0) { @s3_client }
156
158
  @s3_resource = mock(Aws::S3::Resource.new(client: @s3_client))
157
159
  mock(Aws::S3::Resource).new(client: @s3_client) { @s3_resource }
data/test/test_out_s3.rb CHANGED
@@ -10,6 +10,7 @@ require 'zlib'
10
10
  require 'fileutils'
11
11
  require 'timecop'
12
12
  require 'uuidtools'
13
+ require 'ostruct'
13
14
 
14
15
  include Fluent::Test::Helpers
15
16
 
@@ -427,6 +428,7 @@ EOC
427
428
 
428
429
  def setup_mocks(exists_return = false)
429
430
  @s3_client = stub(Aws::S3::Client.new(stub_responses: true))
431
+ stub(@s3_client).config { OpenStruct.new({region: "us-east-1"}) }
430
432
  # aws-sdk-s3 calls Client#put_object inside Object#put
431
433
  mock(@s3_client).put_object(anything).at_least(0) { MockResponse.new({}) }
432
434
  mock(Aws::S3::Client).new(anything).at_least(0) { @s3_client }
@@ -464,6 +466,7 @@ EOC
464
466
 
465
467
  def setup_mocks_hardened_policy()
466
468
  @s3_client = stub(Aws::S3::Client.new(:stub_responses => true))
469
+ stub(@s3_client).config { OpenStruct.new({region: "us-east-1"}) }
467
470
  mock(@s3_client).put_object(anything).at_least(0) { MockResponse.new({}) }
468
471
  mock(Aws::S3::Client).new(anything).at_least(0) { @s3_client }
469
472
  @s3_resource = mock(Aws::S3::Resource.new(:client => @s3_client))
@@ -564,6 +567,32 @@ EOC
564
567
  assert_equal(expected_credentials, credentials)
565
568
  end
566
569
 
570
+ def test_web_identity_credentials
571
+ expected_credentials = Aws::Credentials.new("test_key", "test_secret")
572
+ mock(Aws::AssumeRoleWebIdentityCredentials).new(
573
+ role_arn: "test_arn",
574
+ role_session_name: "test_session",
575
+ web_identity_token_file: "test_file",
576
+ client: anything
577
+ ){
578
+ expected_credentials
579
+ }
580
+
581
+ config = CONFIG_TIME_SLICE.split("\n").reject{|x| x =~ /.+aws_.+/}.join("\n")
582
+ config += %[
583
+ <web_identity_credentials>
584
+ role_arn test_arn
585
+ role_session_name test_session
586
+ web_identity_token_file test_file
587
+ </web_identity_credentials>
588
+ ]
589
+ d = create_time_sliced_driver(config)
590
+ assert_nothing_raised { d.run {} }
591
+ client = d.instance.instance_variable_get(:@s3).client
592
+ credentials = client.config.credentials
593
+ assert_equal(expected_credentials, credentials)
594
+ end
595
+
567
596
  def test_instance_profile_credentials
568
597
  expected_credentials = Aws::Credentials.new("test_key", "test_secret")
569
598
  mock(Aws::InstanceProfileCredentials).new({}).returns(expected_credentials)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-11-11 00:00:00.000000000 Z
12
+ date: 2020-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -37,28 +37,28 @@ dependencies:
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '1.60'
41
41
  type: :runtime
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.0'
47
+ version: '1.60'
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: aws-sdk-sqs
50
50
  requirement: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.0'
54
+ version: '1.23'
55
55
  type: :runtime
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.0'
61
+ version: '1.23'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: rake
64
64
  requirement: !ruby/object:Gem::Requirement