Using aws-elixir and local Minio

Hi,

I am trying to use aws-elixir to access local Minio, any example code to refer to?

Thanks,
Partha

Happy to help. What have you tried?

2 Likes

Managed to get it working. Documenting the steps for others. If there is better way, please do let me know

  1. Running Minio locally at 9000
  2. Have the Client created as follows

iex(1)> client = AWS.Client.create(“id”, “key”, “localhost”)
iex(2)> client = %{client | port: 9000}
iex(3)> client = %{client | proto: “http”}
iex(4)> client = %{client | endpoint: “localhost”}

#AWS.Client<
  region: "localhost",
  service: nil,
  endpoint: "localhost",
  proto: "http",
  port: 9000,
  http_client: {AWS.HTTPClient.Hackney, []},
  json_module: {AWS.JSON, []},
  xml_module: {AWS.XML, []},
  ...

Then used it to invoke

iex(5)> AWS.S3.create_bucket(client, “mybucket”, %{})

{:ok, nil,
 %{
   body: "",
   headers: [
     {"Server", "nginx/1.19.2"},
     {"Date", "Tue, 03 Oct 2023 22:30:21 GMT"},
     {"Content-Length", "0"},
     {"Connection", "keep-alive"},
     {"Accept-Ranges", "bytes"},
     {"Location", "/mybucket"},
     {"Strict-Transport-Security", "max-age=31536000; includeSubDomains"},
     {"Vary", "Origin"},
     {"Vary", "Accept-Encoding"},
     {"X-Amz-Id-2",
      "e0c385c033c4356721cc9121d3109c9b9bfdefb22fd2747078acd22328799e36"},
     {"X-Amz-Request-Id", "178AB98C4ABCE5E0"},
     {"X-Content-Type-Options", "nosniff"},
     {"X-Xss-Protection", "1; mode=block"}
   ],
   status_code: 200
 }}
1 Like

Sorry, I don’t understand the context. What’s AWS.Client, maybe you aliased something ? I am looking to do the same actually.

I guess OP was using this module? AWS.Client — aws-elixir v1.0.3

The library has evolved since October 2023, but this module still exists. (Didn’t try to run this code though.)

1 Like

Nice, this works fine to me too!