-> "Cannot find resource cognitect/aws/kms/service.edn." for this:
(aws/client {:api :kms
:credentials-provider (creds/basic-credentials-provider {:access-key-id (get-env "AWS_ACCESS_KEY_ID")
:secret-access-key (get-env "AWS_SECRET_ACCESS_KEY")})})
do you have this package in your dependencies? https://mvnrepository.com/artifact/com.cognitect.aws/kms
ah ok
makes sense
π
could be a better error though for this
but thanks π
#error{:cause "getProperties",
:via [{:type clojure.lang.Compiler$CompilerException,
:message "Syntax error compiling . at (cognitect/http_client.clj:41:9).",
:data #:clojure.error{:phase :compile-syntax-check,
:line 41,
:column 9,
:source "cognitect/http_client.clj",
:symbol .},
:at [clojure.lang.Compiler analyzeSeq "Compiler.java" 7132]}
{:type java.lang.NoSuchFieldException,
:message "getProperties",
:at [java.lang.Class getField "Class.java" 2149]}],
:trace [[java.lang.Class getField "Class.java" 2149]anything about this?
I'd guess you have a library version conflict somewhere in your deps... Can you share your deps.edn?
Or you could probably run clojure -X:deps tree and get the full tree... I believe the Cognitect AWS library depends on Jetty 9.4 for a client, so if you have a later version of Jetty on your classpath, that might cause it.
We had to switch to io.github.grzm/awyeah-api to avoid the Jetty conflict.
there's also a fork posted on the issue that works for Jetty 12 https://github.com/cognitect-labs/aws-api/issues/181#issuecomment-2293312773
(we're on Jetty 11, via Ring 1.12.2)
ah ok
that was it, thanks π
Which are the versions of aws-api compatible with datomic cloud ions?
why is it happening?
What is the best way to capture the region using the Cognitect API when the app is running on Elastic Beanstalk (or EC2)? I want to avoid hardcoding the region.
Metadata service should provide you with all of the necessary details
Oh true... (System/getenv "AWS_REGION")
I recently deployed a small jar file to Elastic Beanstalk to test, but it appears that (System/getenv "AWS_REGION") is returning as NULL. Any insights would be greatly appreciated.
I found https://docs.aws.amazon.com/en_us/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
(def base-url "")
(def http-opts {:socket-timeout 1000 :connection-timeout 1000})
(defn get-imdsv2-token []
(try
(:body (client/put (str base-url "/api/token")
(assoc http-opts :headers {"X-aws-ec2-metadata-token-ttl-seconds" "21600"})))
(catch Exception _ nil)))
(defn get-instance-region []
(when-let [token (get-imdsv2-token)]
(try
(-> (client/get (str base-url "/meta-data/placement/availability-zone")
(assoc http-opts :headers {"X-aws-ec2-metadata-token" token}))
:body
butlast
str/join)
(catch Exception _ nil))))
This worked.or if u can use IMDSv1, u can just do this:
user=> (slurp "")
"ap-east-1" Yep thatβs exactly what I meant π