module Fluent::Plugin::KinesisHelper::Client
Public Class Methods
included(mod)
click to toggle source
# File lib/fluent/plugin/kinesis_helper/client.rb, line 68 def self.included(mod) mod.include ClientParams end
Public Instance Methods
client()
click to toggle source
# File lib/fluent/plugin/kinesis_helper/client.rb, line 77 def client @client ||= client_class.new(client_options) end
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/kinesis_helper/client.rb, line 72 def configure(conf) super @region = client.config.region if @region.nil? end
Private Instance Methods
aws_sdk_v2?()
click to toggle source
# File lib/fluent/plugin/kinesis_helper/client.rb, line 83 def aws_sdk_v2? @aws_sdk_v2 ||= Gem.loaded_specs['aws-sdk-core'].version < Gem::Version.create('3') end
client_class()
click to toggle source
# File lib/fluent/plugin/kinesis_helper/client.rb, line 87 def client_class case request_type when :streams, :streams_aggregated if aws_sdk_v2? require 'aws-sdk' else require 'aws-sdk-kinesis' end Aws::Kinesis::Client when :firehose if aws_sdk_v2? require 'aws-sdk' else require 'aws-sdk-firehose' end Aws::Firehose::Client end end
client_options()
click to toggle source
# File lib/fluent/plugin/kinesis_helper/client.rb, line 106 def client_options options = setup_credentials options.update( user_agent_suffix: "fluent-plugin-kinesis/#{request_type}/#{FluentPluginKinesis::VERSION}" ) options.update(region: @region) unless @region.nil? options.update(http_proxy: @http_proxy) unless @http_proxy.nil? options.update(endpoint: @endpoint) unless @endpoint.nil? options.update(ssl_verify_peer: @ssl_verify_peer) unless @ssl_verify_peer.nil? if @debug options.update(logger: Logger.new(log.out)) options.update(log_level: :debug) end options end
setup_credentials()
click to toggle source
# File lib/fluent/plugin/kinesis_helper/client.rb, line 122 def setup_credentials options = {} credentials_options = {} case when @aws_key_id && @aws_sec_key options[:access_key_id] = @aws_key_id options[:secret_access_key] = @aws_sec_key when @assume_role_credentials c = @assume_role_credentials credentials_options[:role_arn] = c.role_arn credentials_options[:role_session_name] = c.role_session_name credentials_options[:policy] = c.policy if c.policy credentials_options[:duration_seconds] = c.duration_seconds if c.duration_seconds credentials_options[:external_id] = c.external_id if c.external_id if c.sts_http_proxy and @region credentials_options[:client] = Aws::STS::Client.new(region: @region, http_proxy: c.sts_http_proxy) elsif @region credentials_options[:client] = Aws::STS::Client.new(region: @region) elsif c.sts_http_proxy credentials_options[:client] = Aws::STS::Client.new(http_proxy: c.sts_http_proxy) end options[:credentials] = Aws::AssumeRoleCredentials.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 credentials_options[:http_open_timeout] = c.http_open_timeout if c.http_open_timeout credentials_options[:http_read_timeout] = c.http_read_timeout if c.http_read_timeout if ENV["AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"] options[:credentials] = Aws::ECSCredentials.new(credentials_options) else options[:credentials] = Aws::InstanceProfileCredentials.new(credentials_options) end when @shared_credentials c = @shared_credentials credentials_options[:path] = c.path if c.path credentials_options[:profile_name] = c.profile_name if c.profile_name options[:credentials] = Aws::SharedCredentials.new(credentials_options) else # Use default credentials # See http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html end options end