aws

2024-09-19T00:08:15.363679Z

-> "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")})})

2024-09-19T00:10:06.656759Z

do you have this package in your dependencies? https://mvnrepository.com/artifact/com.cognitect.aws/kms

2024-09-19T00:10:17.539039Z

ah ok

2024-09-19T00:10:19.603619Z

makes sense

2024-09-19T00:10:20.328249Z

πŸ˜„

2024-09-19T00:10:39.379069Z

could be a better error though for this

2024-09-19T00:10:42.365459Z

but thanks πŸ˜„

πŸ‘ 2
2024-09-19T00:16:51.792559Z

#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]

2024-09-19T00:16:52.068609Z

anything about this?

seancorfield 2024-09-19T00:21:20.454509Z

I'd guess you have a library version conflict somewhere in your deps... Can you share your deps.edn?

seancorfield 2024-09-19T00:22:22.862619Z

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.

☝️ 2
seancorfield 2024-09-19T00:23:07.828639Z

We had to switch to io.github.grzm/awyeah-api to avoid the Jetty conflict.

2024-09-19T00:25:10.356849Z

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

seancorfield 2024-09-19T00:25:35.518109Z

(we're on Jetty 11, via Ring 1.12.2)

2024-09-19T00:27:22.739779Z

ah ok

2024-09-19T00:27:27.500439Z

that was it, thanks πŸ˜„

2024-10-01T21:05:13.240089Z

Which are the versions of aws-api compatible with datomic cloud ions?

2024-09-19T00:08:20.050419Z

why is it happening?

Caio Cascaes 2024-09-19T18:38:21.405159Z

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.

lukasz 2024-09-19T18:48:21.459689Z

Metadata service should provide you with all of the necessary details

Caio Cascaes 2024-09-19T18:51:13.996519Z

Oh true... (System/getenv "AWS_REGION")

Caio Cascaes 2024-09-19T18:52:26.741489Z

Thank you @lukaszkorecki

πŸ‘ 1
Caio Cascaes 2024-09-19T23:18:18.878449Z

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.

Caio Cascaes 2024-09-20T02:07:15.690759Z

(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.

onetom 2024-10-29T17:26:17.524249Z

or if u can use IMDSv1, u can just do this:

user=> (slurp "")
"ap-east-1"

πŸ‘ 2
lukasz 2024-09-20T14:29:49.870709Z

Yep that’s exactly what I meant πŸ‘

πŸ‘ 1