AWS Request Signature mismatch only for post query
chrisstpierre opened this issue · 2 comments
chrisstpierre commented
My Config:
config :app, App.Elasticsearch.Cluster,
url: "https://redacted.us-east-1.es.amazonaws.com",
api: Elasticsearch.API.AWS,
default_options: [
aws: [
region: "us-east-1",
service: "es",
access_key: "redacted",
secret: "redacted"
]
],
json_library: Jason
Getting a document:
IO.inspect(
Elasticsearch.get(
App.Elasticsearch.Cluster,
"/movies/_doc/5"
)
)
{:ok,
%{
"_id" => "5",
"_index" => "movies",
"_primary_term" => 1,
"_seq_no" => 0,
"_source" => %{
"director" => "Bennett Miller",
"title" => "Moneyball",
"year" => "2011"
},
"_type" => "_doc",
"_version" => 1,
"found" => true
}}
My Query that does not work
index_pattern = "/employees-*/_search"
query = %{
"suggest" => %{
"employee-suggest" => %{
"prefix" => "An",
"completion" => %{
"field" => "name_suggest",
"size" => 10,
"skip_duplicates" => true,
"fuzzy" => %{
"fuzziness" => 1
}
}
}
}
}
IO.inspect(
Elasticsearch.post(
App.Elasticsearch.Cluster,
index_pattern,
query
)
)
{:error,
%Elasticsearch.Exception{
col: nil,
line: nil,
message: "The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.",
query: nil,
raw: %{
"message" => "The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."
},
status: nil,
type: nil
}}
Doing the same query with Postman does not fail like it does in the Elixir application. What is going on here?
danielberkompas commented
I'm closing this because it's an old issue. I believe this was probably a misconfiguration, not a problem with the library itself because I believe many people are using it with AWS successfully.
dsaradini commented
Just in case someone have the same problem using post _search
@chrisstpierre The problem is related to the "*" in your url, you must encode it using %2A, try this:
index_pattern = "/employees-%2A/_search"