Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions aws-api-s3/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ pom.xml.asc
/.nrepl-port
.hgignore
.hg/
/.idea/
/aws-api-s3.iml
6 changes: 3 additions & 3 deletions aws-api-s3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
12 changes: 12 additions & 0 deletions aws-api-s3/graalvm-resources/resource-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"resources": {
"includes": [
{
"pattern": "cognitect/aws/.+\\.edn"
},
{
"pattern" : "cognitect_aws_http.edn"
}
]
}
}
34 changes: 18 additions & 16 deletions aws-api-s3/project.clj
Original file line number Diff line number Diff line change
@@ -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}"]
Expand Down
2 changes: 2 additions & 0 deletions aws-api-s3/resources/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{:access-key-id "RANDOM-ACCESS-KEY-ID"
:secret-access-key "random/secret/access-key"}
13 changes: 10 additions & 3 deletions aws-api-s3/src/simple/main.clj
Original file line number Diff line number Diff line change
@@ -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}))))