diff --git a/aws-api-s3/.gitignore b/aws-api-s3/.gitignore index d18f225..47d37e3 100644 --- a/aws-api-s3/.gitignore +++ b/aws-api-s3/.gitignore @@ -10,3 +10,5 @@ pom.xml.asc /.nrepl-port .hgignore .hg/ +/.idea/ +/aws-api-s3.iml diff --git a/aws-api-s3/README.md b/aws-api-s3/README.md index f9e5ba2..a516f37 100644 --- a/aws-api-s3/README.md +++ b/aws-api-s3/README.md @@ -6,9 +6,9 @@ Testing whether [cognitect/aws-api+s3](https://github.com/cognitect-labs/aws-api Currently testing: - [com.cognitect.aws/api "0.8.301"] - [com.cognitect.aws/endpoints "1.1.11.537"] - [com.cognitect.aws/s3 "714.2.430.0"] + [com.cognitect.aws/api "0.8.692"] + [com.cognitect.aws/endpoints "1.1.12.772"] + [com.cognitect.aws/s3 "869.2.1687.0"] Gotchas: diff --git a/aws-api-s3/graalvm-resources/resource-config.json b/aws-api-s3/graalvm-resources/resource-config.json new file mode 100644 index 0000000..e11566a --- /dev/null +++ b/aws-api-s3/graalvm-resources/resource-config.json @@ -0,0 +1,12 @@ +{ + "resources": { + "includes": [ + { + "pattern": "cognitect/aws/.+\\.edn" + }, + { + "pattern" : "cognitect_aws_http.edn" + } + ] + } +} diff --git a/aws-api-s3/project.clj b/aws-api-s3/project.clj index f297030..6506ae4 100644 --- a/aws-api-s3/project.clj +++ b/aws-api-s3/project.clj @@ -1,30 +1,32 @@ (defproject aws-api-s3 "0.1.0-SNAPSHOT" - :dependencies [[org.clojure/clojure "1.10.2-rc1"] - [com.cognitect.aws/api "0.8.484"] - [com.cognitect.aws/endpoints "1.1.11.926"] - [com.cognitect.aws/s3 "810.2.817.0"]] + :dependencies [[org.clojure/clojure "1.12.0"] + [com.cognitect.aws/api "0.8.692"] + [com.cognitect.aws/endpoints "1.1.12.772"] + [com.cognitect.aws/s3 "869.2.1687.0"] + [com.github.clj-easy/graal-build-time "1.0.5"]] :main simple.main :uberjar-name "simple-main.jar" :profiles {:uberjar {:aot :all} - :dev {:plugins [[lein-shell "0.5.0"]]}} + :dev {:plugins [[lein-shell "0.5.0"]]}} :aliases - {"native-config" + {"native" ["shell" - ;; run the application to infer the build configuration - "java" "-agentlib:native-image-agent=config-output-dir=./target/config/" - "-jar" "./target/${:uberjar-name:-${:name}-${:version}-standalone.jar}"] - - "native" - ["shell" - "native-image" "--report-unsupported-elements-at-runtime" "--no-server" "--no-fallback" - "-H:+PrintClassInitialization" - "-H:ConfigurationFileDirectories=./target/config/" - "--initialize-at-build-time" + "native-image" + "--no-fallback" + "--report-unsupported-elements-at-runtime" + "--no-server" "--allow-incomplete-classpath" + "--initialize-at-build-time" + "-H:+PrintClassInitialization" + "--features=clj_easy.graal_build_time.InitClojureClasses" + + "-H:+UnlockExperimentalVMOptions" + "-H:ConfigurationFileDirectories=graalvm-resources" + "--enable-http" "--enable-https" "--enable-all-security-services" "-jar" "./target/${:uberjar-name:-${:name}-${:version}-standalone.jar}" "-H:Name=./target/${:name}"] diff --git a/aws-api-s3/resources/config.edn b/aws-api-s3/resources/config.edn new file mode 100644 index 0000000..80bad4f --- /dev/null +++ b/aws-api-s3/resources/config.edn @@ -0,0 +1,2 @@ +{:access-key-id "RANDOM-ACCESS-KEY-ID" + :secret-access-key "random/secret/access-key"} diff --git a/aws-api-s3/src/simple/main.clj b/aws-api-s3/src/simple/main.clj index 5b2fd6f..a2fc66c 100644 --- a/aws-api-s3/src/simple/main.clj +++ b/aws-api-s3/src/simple/main.clj @@ -1,18 +1,25 @@ (ns simple.main - (:require [cognitect.aws.client.api :as aws] + (:require [clojure.edn :as edn] + [cognitect.aws.client.api :as aws] + [cognitect.aws.credentials :as credentials] ;; add this for graalvm (explicit load) ;; there are dynamically loaded at runtime [cognitect.aws.http.cognitect] [cognitect.aws.protocols.json] - [cognitect.aws.protocols.common] [cognitect.aws.protocols.rest] [cognitect.aws.protocols.rest-xml] [clojure.spec.alpha]) (:gen-class)) +(defn fetch-config [] + (edn/read-string (slurp "resources/config.edn"))) + (defn -main [] ;; create a http-client and pass it while create aws clients to avoid dynamic loading ;; use a `delay` if you want to share the http-client across many aws-clients - (let [s3 (aws/client {:api :s3 :http-client (cognitect.aws.http.cognitect/create)})] + (let [config (fetch-config) + s3 (aws/client {:api :s3 + :http-client (cognitect.aws.http.cognitect/create) + :credentials-provider (credentials/basic-credentials-provider config)})] (prn (aws/invoke s3 {:op :ListBuckets}))))