Commit d06660a43dbadd7bbf40d0cdf017a685437210fe
1 parent
7f9e08f4
Exists in
master
and in
21 other branches
Easier AWS setup
Showing
2 changed files
with
16 additions
and
0 deletions
Show diff stats
CHANGELOG.md
lib/searchkick.rb
... | ... | @@ -31,6 +31,7 @@ module Searchkick |
31 | 31 | class << self |
32 | 32 | attr_accessor :search_method_name, :wordnet_path, :timeout, :models |
33 | 33 | attr_writer :client, :env, :search_timeout |
34 | + attr_reader :aws_credentials | |
34 | 35 | end |
35 | 36 | self.search_method_name = :search |
36 | 37 | self.wordnet_path = "/var/lib/wn_s.pl" |
... | ... | @@ -46,6 +47,11 @@ module Searchkick |
46 | 47 | transport_options: {request: {timeout: timeout}, headers: {content_type: "application/json"}} |
47 | 48 | ) do |f| |
48 | 49 | f.use Searchkick::Middleware |
50 | + f.request :aws_signers_v4, { | |
51 | + credentials: Aws::Credentials.new(aws_credentials[:access_key_id], aws_credentials[:secret_access_key]), | |
52 | + service_name: "es", | |
53 | + region: aws_credentials[:region] || "us-east-1" | |
54 | + } if aws_credentials | |
49 | 55 | end |
50 | 56 | end |
51 | 57 | end |
... | ... | @@ -93,6 +99,12 @@ module Searchkick |
93 | 99 | end |
94 | 100 | end |
95 | 101 | |
102 | + def self.aws_credentials=(creds) | |
103 | + require "faraday_middleware/aws_signers_v4" | |
104 | + @aws_credentials = creds | |
105 | + @client = nil # reset client | |
106 | + end | |
107 | + | |
96 | 108 | # private |
97 | 109 | def self.queue_items(items) |
98 | 110 | queued_items.concat(items) | ... | ... |