ex-aws / ex_aws

A flexible, easy to use set of clients AWS APIs for Elixir
https://hex.pm/packages/ex_aws
MIT License
1.28k stars 527 forks source link

Any way to overcome <service> not supported in region <region> for partition aws? #682

Open kw7oe opened 4 years ago

kw7oe commented 4 years ago

Environment

Elixir 1.9.4 (compiled with Erlang/OTP 20)


* ExAws version `mix deps |grep ex_aws`

Current behavior

Currently, whenever we are trying to use a service that are supported AWS but not included in priv/endpoints.exs, we will faced the (RuntimeError) <service> not supported in region <region>.... For example:

ExAws.Operation.JSON.new(:sagemaker_runtime, %{
  http_method: :post,
  path: "/endpoint/model-name/invocations",
  data: "{\"id\":\"271dcf6e-7fff-46d0-847a-f1add6b7bbeb\",\"image_url\":\"http://example.com/image.jpg\"}",
  headers: [{"content-type", "application/json"}]
}) |> ExAws.request!()

will raise:

** (RuntimeError) sagemaker_runtime not supported in region ap-southeast-1 for partition aws
    (ex_aws) lib/ex_aws/config/defaults.ex:140: ExAws.Config.Defaults.fetch_or/3
    (ex_aws) lib/ex_aws/config/defaults.ex:123: ExAws.Config.Defaults.do_host/3
    (ex_aws) lib/ex_aws/config/defaults.ex:60: ExAws.Config.Defaults.get/2
    (ex_aws) lib/ex_aws/config.ex:47: ExAws.Config.build_base/2
    (ex_aws) lib/ex_aws/config.ex:34: ExAws.Config.new/2
    (ex_aws) lib/ex_aws.ex:50: ExAws.request/2
    (ex_aws) lib/ex_aws.ex:61: ExAws.request!/2

Expected behavior

Is there anyway to overcome this (without forking and editing priv/endpoints.exs)? Pinpointing me to the right direction would be sufficient.

Would also willing to contribute if there is any plan for long term fixes.

Anyway, thanks for making this library 💯

jnylen commented 3 years ago

Indeed @kw7oe, There should be a way to bypass it when the developer knows the region exists and that the service supports it.

Either by a bypass_checks: true or just bypass it completely when the host doesn't have an amazon-specific domain. These checks basically ruins an easy addition of a third-party provider such as DO or Backblaze.

bernardd commented 3 years ago

Remember, though, that the endpoints file doesn't just check for the existence of a service/location but also contains any specific configuration for it. Having said that, I'm aware it's a pain since, besides anything else, AWS is constantly adding stuff.

I think a better solution might be to allow runtime patching of the endpoint data so that you don't have to wait for version updates if you know something is available. I'd be more than happy to consider a patch for that.

acrolink commented 3 months ago

So the solution is only to fork ? Or wait for new releases ?