babashka / pod-babashka-aws

Deprecated, use https://github.com/grzm/awyeah-api
Apache License 2.0
61 stars 14 forks source link

Upload something to S3 test #7

Closed borkdude closed 3 years ago

borkdude commented 3 years ago
#!/usr/bin/env bb
(ns script
  (:require [babashka.pods :as pods]))
(pods/load-pod "./pod-babashka-aws")
(require '[pod.babashka.aws :as aws])
(def s3 (aws/client {:api :s3}))
(aws/doc s3 :CreateBucket)
(prn (aws/invoke s3 {:op :CreateBucket :request {:Bucket "michiel-bucket"}}))
(prn (-> (aws/invoke s3 {:op :ListBuckets})
        :Buckets))

I'm getting:

 Message:  java.lang.Exception: Not supported: class java.lang.IllegalArgumentException
Location: /tmp/s3.clj:14:6

Any ideas @lispyclouds @jeroenvandijk ?

borkdude commented 3 years ago

In clojure I'm getting:

{:Error {:Code "IllegalLocationConstraintException", :CodeAttrs {}, :Message "The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.", :MessageAttrs {}, :RequestId "A4F459512AE95690", :RequestIdAttrs {}, :HostId "M1pgyjwFZQwJWxZqGWJR7BYI3LSr+yR9yAULcYO/cUoh9DAlkWb00T3l4x4c5BPRRnzL6QmUMGg=", :HostIdAttrs {}}, :ErrorAttrs {}, :cognitect.anomalies/category :cognitect.anomalies/incorrect}
[{:Name "rotocode.dre", :CreationDate #inst "2020-07-07T07:32:16.000-00:00"}]

It seems error handling is not perfect yet. After further investigation, it turns out to be a difference between JVM and native.

borkdude commented 3 years ago

better:


Exception in thread "main" java.lang.RuntimeException: java.lang.Exception: Not supported: class java.lang.IllegalArgumentException
    at com.cognitect.transit.impl.WriterFactory$1.write(WriterFactory.java:65)
    at cognitect.transit$write.invokeStatic(transit.clj:171)
    at cognitect.transit$write.invoke(transit.clj:168)
    at pod.babashka.aws$write_transit.invokeStatic(aws.clj:74)
    at pod.babashka.aws$write_transit.invoke(aws.clj:72)
    at pod.babashka.aws$_main$fn__11212$fn__11213.invoke(aws.clj:102)
    at pod.babashka.aws$_main$fn__11212.invoke(aws.clj:101)
    at pod.babashka.aws$_main.invokeStatic(aws.clj:92)
    at pod.babashka.aws$_main.doInvoke(aws.clj:77)
    at clojure.lang.RestFn.invoke(RestFn.java:397)
    at clojure.lang.AFn.applyToHelper(AFn.java:152)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at pod.babashka.aws.main(Unknown Source)
Caused by: java.lang.Exception: Not supported: class java.lang.IllegalArgumentException
    at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:194)
    at com.cognitect.transit.impl.JsonEmitter.emitMap(JsonEmitter.java:171)
    at com.cognitect.transit.impl.AbstractEmitter.emitMap(AbstractEmitter.java:85)
    at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:184)
    at com.cognitect.transit.impl.AbstractEmitter.marshalTop(AbstractEmitter.java:211)
    at com.cognitect.transit.impl.JsonEmitter.emit(JsonEmitter.java:41)
    at com.cognitect.transit.impl.WriterFactory$1.write(WriterFactory.java:62)
    ... 12 more```

so this `:cognitect.aws.client/throwable` key is something we should datafy or something first
because transit doesn't know
borkdude commented 3 years ago

We're running into reflection warnings it seems with GraalVM native-image. Fixed in https://github.com/cognitect-labs/aws-api/commit/b65d61d6e69880786061d8c7ad5893cce8bc14a8. Luckily we're using deps.edn so we can just use it from master.