mcohen01 / amazonica

A comprehensive Clojure client for the entire Amazon AWS api.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trouble using amazonica with Minio for s3

francoisdevlin opened this issue · comments

commented

I'm trying to use amazonica with Minio for s3, it's similar to localstack. I've already looked at these two issues and they provided limited help

I copied from here as best I could:
https://github.com/mcohen01/amazonica#s3

Here's my code:

(def cred {:access-key ""
           :secret-key ""
           :endpoint "http://s3:9000"
           :client-config
           {
            :path-style-access-enabled true
            }})

;This works as expected...
(-> cred s3/list-buckets println)
(-> cred (s3/create-bucket "test-bucket-bacon"))

(-> cred (s3/list-objects "test-bucket-bacon") println)
;; Things break down here
;; put object from stream
(def some-bytes (.getBytes "Amazonica" "UTF-8"))
(def input-stream (java.io.ByteArrayInputStream. some-bytes))
(s3/put-object :bucket-name "my-bucket" :key "stream" :input-stream input-stream :metadata {:content-length (count some-bytes)})

I get an exception related to not providing a region

#error {
 :cause Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message Syntax error compiling at (raven/core/blobs.clj:62:1).
   :data #:clojure.error{:phase :compile-syntax-check, :line 62, :column 1, :source raven/core/blobs.clj}
   :at [clojure.lang.Compiler load Compiler.java 7647]}
  {:type com.amazonaws.SdkClientException
   :message Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
   :at [com.amazonaws.client.builder.AwsClientBuilder setRegion AwsClientBuilder.java 462]}]
 :trace
 [[com.amazonaws.client.builder.AwsClientBuilder setRegion AwsClientBuilder.java 462]
  [com.amazonaws.client.builder.AwsClientBuilder configureMutableProperties AwsClientBuilder.java 424]
  [com.amazonaws.client.builder.AwsSyncClientBuilder build AwsSyncClientBuilder.java 46]
  [amazonica.core$build_client invokeStatic core.clj 165]
  [amazonica.core$build_client invoke core.clj 152]
...

Here's an excerpt from my docker-compose which should do the trick to reproduce this

version: '3.7'
services:
  web:
    ports:
      - "3000:3000"
    volumes:
      - "${PWD}:/usr/src/app"
      - "${HOME}/.m2:/root/.m2"
    image: clojure
    command: "lein repl"
    working_dir: "/usr/src/app"
    links:
      - s3
  s3:
    ports:
      - "9000:9000"
    image: minio/minio
    command: "server /data"
    environment:
      - "MINIO_ACCESS_KEY=KEY"
      - "MINIO_SECRET_KEY=SECRET"
      - "MINIO_REGION_NAME=my_region"

Run with docker-compose run --rm web lein repl

Any help would be appreciated, thanks

commented

Disregard, the error is now staring me in the face. I didn't pass the creds into the last function call.

Thanks for the library