I’m trying to make requests using ExAws
to SQS queues in different regions using different configs but I’ve come across some behaviour that I don’t understand. Normally, given that the library’s default region is us-east-1
, I can do the following:
iex(1)> ExAws.SQS.list_queues() |> ExAws.request
and I get the appropriate response. Let’s say I want to do the same thing for us-west in the same program, this is how I’d go about it:
iex(2)> conf = ExAws.Config.new(:sqs, [region: "us-west-1"])
%{access_key_id: "MY_ACCESS_KEY_ID", host: "sqs.us-west-1.amazonaws.com",
http_client: ExAws.Request.Hackney, json_codec: Poison, port: 443,
region: "us-east-1",
retries: [max_attempts: 10, base_backoff_in_ms: 10, max_backoff_in_ms: 10000],
scheme: "https://",
secret_access_key: "MY_SECRET_KEY"}
iex(4)> ExAws.SQS.list_queues() |> ExAws.request(conf)
{:error,
{:http_error, 403,
%{code: "SignatureDoesNotMatch", detail: "",
message: "Credential should be scoped to a valid region, not 'us-east-1'. ",
request_id: "my_request_id", type: "Sender"}}}
which obviously results in error. What’s interesting to note is that the config returned in ExAws.Config.new/2
has the appropriate host but an incorrect region. This is seen in the following:
iex(4)> conf2 = conf |> Map.merge(%{:region => "us-west-1"})
iex(5)> ExAws.SQS.list_queues() |> ExAws.request(conf2) # returns the correct result
Perhaps I’m misunderstanding how configuration is supposed to work with this library and would appreciate any sort of guidance as to how I’m supposed to achieve my desired outcome.
Thanks!