lib/fluent/plugin/out_s3.rb in fluent-plugin-s3-1.2.1 vs lib/fluent/plugin/out_s3.rb in fluent-plugin-s3-1.3.0

- old
+ new

@@ -38,10 +38,24 @@ desc "The duration, in seconds, of the role session (900-3600)" config_param :duration_seconds, :integer, default: nil desc "A unique identifier that is used by third parties when assuming roles in their customers' accounts." config_param :external_id, :string, default: nil, secret: true end + # See the following link for additional params that could be added: + # https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/STS/Client.html#assume_role_with_web_identity-instance_method + config_section :web_identity_credentials, multi: false do + desc "The Amazon Resource Name (ARN) of the role to assume" + config_param :role_arn, :string # required + desc "An identifier for the assumed role session" + config_param :role_session_name, :string #required + desc "The absolute path to the file on disk containing the OIDC token" + config_param :web_identity_token_file, :string #required + desc "An IAM policy in JSON format" + config_param :policy, :string, default: nil + desc "The duration, in seconds, of the role session (900-43200)" + config_param :duration_seconds, :integer, default: nil + end config_section :instance_profile_credentials, multi: false do desc "Number of times to retry when retrieving credentials" config_param :retries, :integer, default: nil desc "IP address (default:169.254.169.254)" config_param :ip_address, :string, default: nil @@ -173,11 +187,11 @@ if @hex_random_length > MAX_HEX_RANDOM_LENGTH raise Fluent::ConfigError, "hex_random_length parameter must be less than or equal to #{MAX_HEX_RANDOM_LENGTH}" end unless @index_format =~ /^%(0\d*)?[dxX]$/ - 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" + 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" end if @reduced_redundancy log.warn "reduced_redundancy parameter is deprecated. Use storage_class parameter instead" @storage_class = "REDUCED_REDUNDANCY" @@ -458,9 +472,20 @@ credentials_options[:external_id] = c.external_id if c.external_id if @s3_region credentials_options[:client] = Aws::STS::Client.new(region: @s3_region) end options[:credentials] = Aws::AssumeRoleCredentials.new(credentials_options) + when @web_identity_credentials + c = @web_identity_credentials + credentials_options[:role_arn] = c.role_arn + credentials_options[:role_session_name] = c.role_session_name + credentials_options[:web_identity_token_file] = c.web_identity_token_file + credentials_options[:policy] = c.policy if c.policy + credentials_options[:duration_seconds] = c.duration_seconds if c.duration_seconds + if @s3_region + credentials_options[:client] = Aws::STS::Client.new(:region => @s3_region) + end + options[:credentials] = Aws::AssumeRoleWebIdentityCredentials.new(credentials_options) when @instance_profile_credentials c = @instance_profile_credentials credentials_options[:retries] = c.retries if c.retries credentials_options[:ip_address] = c.ip_address if c.ip_address credentials_options[:port] = c.port if c.port