class Fluent::Plugin::AwsElasticsearchServiceOutput
Public Instance Methods
get_connection_options()
click to toggle source
@override
# File lib/fluent/plugin/out_aws-elasticsearch-service.rb, line 33 def get_connection_options raise "`endpoint` require." if @endpoint.empty? hosts = begin @endpoint.map do |ep| uri = URI(ep[:url]) host = %w(user password path).inject(host: uri.host, port: uri.port, scheme: uri.scheme) do |hash, key| hash[key.to_sym] = uri.public_send(key) unless uri.public_send(key).nil? || uri.public_send(key) == '' hash end host[:aws_elasticsearch_service] = { :credentials => credentials(ep), :region => ep[:region] } host end end { hosts: hosts } end
write(chunk)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_aws-elasticsearch-service.rb, line 59 def write(chunk) super end
Private Instance Methods
credentials(opts)
click to toggle source
get AWS Credentials
# File lib/fluent/plugin/out_aws-elasticsearch-service.rb, line 69 def credentials(opts) calback = lambda do credentials = nil unless opts[:access_key_id].empty? or opts[:secret_access_key].empty? credentials = Aws::Credentials.new opts[:access_key_id], opts[:secret_access_key] else if opts[:assume_role_arn].nil? if opts[:ecs_container_credentials_relative_uri].nil? credentials = Aws::SharedCredentials.new({retries: 2}).credentials credentials ||= Aws::InstanceProfileCredentials.new.credentials credentials ||= Aws::ECSCredentials.new.credentials else credentials = Aws::ECSCredentials.new({ credential_path: opts[:ecs_container_credentials_relative_uri] }).credentials end else credentials = sts_credential_provider({ role_arn: opts[:assume_role_arn], role_session_name: opts[:assume_role_session_name], region: opts[:region] }).credentials end end raise "No valid AWS credentials found." unless credentials.set? credentials end def calback.inspect credentials = self.call credentials.credentials.inspect end calback end
sts_credential_provider(opts)
click to toggle source
# File lib/fluent/plugin/out_aws-elasticsearch-service.rb, line 103 def sts_credential_provider(opts) # AssumeRoleCredentials is an auto-refreshing credential provider @sts ||= Aws::AssumeRoleCredentials.new(opts) end