This repository is extends of https://github.com/uken/fluent-plugin-elasticsearch/ which made connectable to Amazon Elassticsearch Service using Aws Signers V4. Please check the requirements to connect to Amazon Elassticsearch Service without using Aws Signers V4 for before starting use. (reference https://groups.google.com/forum/#!msg/fluentd/uW87VAOqxeE/cfhenicEBAAJ)
MIT License
122
stars
49
forks
source link
changed the paremeter service_name to service for faraday. #82
require 'aws-sdk'
require 'elasticsearch'
require 'faraday_middleware/aws_sigv4'
region = 'eu-central-1'
service = 'es'
credentials = Aws::AssumeRoleWebIdentityCredentials.new({
role_arn: 'arn:aws:iam::ACCOUNT:role/ROLE',
web_identity_token_file: '/var/run/secrets/eks.amazonaws.com/serviceaccount/token',
region: 'eu-central-1'
}).credentials
full_url_and_port = 'HOST'
index = 'logs-marcus-test'
type = '_doc'
id = '1'
document = {
year: 2007,
title: '5 Centimeters per Second',
info: {
plot: 'Told in three interconnected segments, we follow a young man named Takaki through his life.',
rating: 7.7
}
}
client = Elasticsearch::Client.new(url: full_url_and_port) do |f|
f.request :aws_sigv4,
service_name: service,
region: region,
credentials: credentials
end
puts client.index index: index, type: type, id: id, body: document
Traceback (most recent call last):
16: from /usr/local/bundle/gems/elasticsearch-transport-7.13.3/lib/elasticsearch/transport/transport/base.rb:288:in `perform_request'
15: from /usr/local/bundle/gems/elasticsearch-transport-7.13.3/lib/elasticsearch/transport/transport/http/faraday.rb:48:in `block in perform_request'
14: from /usr/local/bundle/gems/faraday-1.10.0/lib/faraday/connection.rb:516:in `run_request'
13: from /usr/local/bundle/gems/faraday-1.10.0/lib/faraday/rack_builder.rb:154:in `build_response'
12: from /usr/local/bundle/gems/faraday-1.10.0/lib/faraday/rack_builder.rb:167:in `app'
11: from /usr/local/bundle/gems/faraday-1.10.0/lib/faraday/rack_builder.rb:174:in `to_app'
10: from /usr/local/bundle/gems/faraday-1.10.0/lib/faraday/rack_builder.rb:174:in `inject'
9: from /usr/local/bundle/gems/faraday-1.10.0/lib/faraday/rack_builder.rb:174:in `each'
8: from /usr/local/bundle/gems/faraday-1.10.0/lib/faraday/rack_builder.rb:175:in `block in to_app'
7: from /usr/local/bundle/gems/faraday-1.10.0/lib/faraday/rack_builder.rb:57:in `build'
6: from /usr/local/bundle/gems/faraday-1.10.0/lib/faraday/dependency_loader.rb:21:in `new'
5: from /usr/local/bundle/gems/faraday-1.10.0/lib/faraday/dependency_loader.rb:21:in `new'
4: from /usr/local/bundle/gems/faraday_middleware-aws-sigv4-0.3.0/lib/faraday_middleware/request/aws_sigv4.rb:9:in `initialize'
3: from /usr/local/bundle/gems/faraday_middleware-aws-sigv4-0.3.0/lib/faraday_middleware/request/aws_sigv4.rb:9:in `new'
2: from /usr/local/bundle/gems/aws-sigv4-1.4.0/lib/aws-sigv4/signer.rb:122:in `initialize'
1: from /usr/local/bundle/gems/aws-sigv4-1.4.0/lib/aws-sigv4/signer.rb:609:in `extract_service'
ArgumentError (missing required option :service)
faraday_middleware-aws-sigv4 changed to use service instead of service_name https://github.com/winebarrel/faraday_middleware-aws-sigv4#upgrading-from-faraday_middleware-aws-signers-v4