<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged aws-api</title>
<link>https://ask.clojure.org/index.php/tag/aws-api</link>
<description></description>
<item>
<title>How to use the AWS S3 Java API v2 `S3Configuration`?</title>
<link>https://ask.clojure.org/index.php/13794/how-to-use-the-aws-s3-java-api-v2-s3configuration</link>
<description>&lt;p&gt;I want to turn this Java code into Clojure&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;S3Client.builder()
      .serviceConfiguration(S3Configuration.builder()
            .pathStyleAccessEnabled(true)
            .build())
      .build();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The Problem: &lt;code&gt;.seviceConfiguration&lt;/code&gt; takes a &lt;code&gt;java.util.function.Conumser&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;default B serviceConfiguration(Consumer&amp;lt;S3Configuration.Builder&amp;gt; serviceConfiguration)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;.servcieConfiguration method&lt;/code&gt; is defined here &lt;a rel=&quot;nofollow&quot; href=&quot;https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/s3/S3BaseClientBuilder.html#serviceConfiguration(java.util.function.Consumer)&quot;&gt;AWS SDK serviceConfiguration&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I tried to use &lt;code&gt;reify&lt;/code&gt; without much luck.&lt;/p&gt;
&lt;p&gt;Maybe someone can point me into the right direction, or has already used this specific part of the API.&lt;/p&gt;
&lt;p&gt;And can someone tell me why, is an API design like this advantageous for Java Developers, what is the point of this Construct?&lt;/p&gt;
</description>
<category>Java Interop</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13794/how-to-use-the-aws-s3-java-api-v2-s3configuration</guid>
<pubDate>Tue, 26 Mar 2024 08:44:25 +0000</pubDate>
</item>
<item>
<title>Slow creation of aws-api client in lambda</title>
<link>https://ask.clojure.org/index.php/8863/slow-creation-of-aws-api-client-in-lambda</link>
<description>&lt;p&gt;While attempting to retrieve files from S3 within a Lambda function using Cognitect's aws-api, I get unexpected slow behavior. Sample code below was used to get a general sense of the time each relevant operation takes. Getting the client &lt;code&gt;(aws/client {:api :s3})&lt;/code&gt; consistently takes over 4 seconds. As a point of comparison, the same code executing from my local development environment accessing the same S3 bucket/key, executes without the same noticeable delay as when it executes within Lambda.&lt;/p&gt;
&lt;p&gt;I should note that the namespace in which this function resides leverages the gen-class facility. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn read-s3-file
  [bucket obj-key]
  (let [_ (println (str &quot;-----&amp;gt; Before declaring s3 client: &quot; (java.time.LocalDateTime/now)))
        s3 (aws/client {:api :s3})
        _ (println (str &quot;-----&amp;gt; After declaring s3 client: &quot; (java.time.LocalDateTime/now)))
        _ (println (str &quot;---&amp;gt; bucket: &quot; bucket &quot;, key &quot; obj-key))
        body  (:Body (aws/invoke s3 {:op :GetObject :request {:Bucket bucket :Key obj-key}}))
        _ (println (str &quot;-----&amp;gt; After GetObject: &quot; (java.time.LocalDateTime/now)))
        ]
    (println (str &quot;-----&amp;gt; Before calling slurp: &quot; (java.time.LocalDateTime/now)))
    (slurp body)
    )
  )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Would this be caused by the java8 runtime required by Lambda? &lt;/p&gt;
&lt;p&gt;Local output:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clj-lead-updater.core=&amp;gt; (clj-lead-updater.s3/read-s3-file &quot;automattix-incoming-emails&quot; &quot;tdf10001AnsSvc/0dqsmtvh5mquq3tdhpq550lnqcp6162f0k29da01&quot;)
-----&amp;gt; Before declaring s3 client: 2019-11-18T18:52:27.611925
-----&amp;gt; After declaring s3 client: 2019-11-18T18:52:27.638097
---&amp;gt; bucket: automattix-incoming-emails, key tdf10001AnsSvc/0dqsmtvh5mquq3tdhpq550lnqcp6162f0k29da01
-----&amp;gt; After GetObject: 2019-11-18T18:52:28.096044
-----&amp;gt; Before calling slurp: 2019-11-18T18:52:28.096431
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The two relevant measures are:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;-----&amp;gt; Before declaring s3 client: 2019-11-18T18:52:27.611925
-----&amp;gt; After declaring s3 client: 2019-11-18T18:52:27.638097
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Lambda output:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;-----&amp;gt; Before turning input into a map: 2019-11-17T02:27:08.705
-----&amp;gt; Before declaring s3 client: 2019-11-17T02:27:08.781
2019-11-17 02:27:10.641:INFO::main: Logging initialized @8431ms to org.eclipse.jetty.util.log.StdErrLog
-----&amp;gt; After declaring s3 client: 2019-11-17T02:27:12.923
-----&amp;gt; After GetObject: 2019-11-17T02:27:14.446
-----&amp;gt; Before calling slurp: 2019-11-17T02:27:14.446
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And, again, the two relevant measures are:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;-----&amp;gt; Before declaring s3 client: 2019-11-17T02:27:08.781
-----&amp;gt; After declaring s3 client: 2019-11-17T02:27:12.923
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Relevant dependencies in the project:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  [org.clojure/clojure &quot;1.10.1&quot;]
  [com.cognitect.aws/api &quot;0.8.391&quot;]
  [com.cognitect.aws/endpoints &quot;1.1.11.670&quot;]
  [com.cognitect.aws/s3 &quot;770.2.568.0&quot;]
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Libs</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8863/slow-creation-of-aws-api-client-in-lambda</guid>
<pubDate>Mon, 18 Nov 2019 19:57:26 +0000</pubDate>
</item>
<item>
<title>Retrieve S3 Object from a Lambda</title>
<link>https://ask.clojure.org/index.php/8363/retrieve-s3-object-from-a-lambda</link>
<description>&lt;p&gt;I'm attempting to retrieve a file from S3 from within an AWS Lambda using Congitect's &lt;code&gt;aws-api&lt;/code&gt; library with a Java 8 runtime, but I'm consistently having problems:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def s3 (aws/client {:api :s3}))

(defn open-file []
  (aws/invoke s3 {:op :GetObject :request {:Bucket &quot;test-bucket&quot; :Key &quot;filename.txt&quot;}}))

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When calling &lt;code&gt;open-file&lt;/code&gt; I get the following error:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{
  &quot;:cognitect.anomalies/category&quot;: {
    &quot;sym&quot;: {
      &quot;name&quot;: &quot;fault&quot;,
      &quot;namespace&quot;: &quot;cognitect.anomalies&quot;
    },
    &quot;name&quot;: &quot;fault&quot;,
    &quot;namespace&quot;: &quot;cognitect.anomalies&quot;
  },
  &quot;:cognitect.anomalies/message&quot;: &quot;java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;&quot;,
  &quot;:cognitect.http-client/throwable&quot;: {
    &quot;stackTrace&quot;: [
      {
        &quot;methodName&quot;: &quot;invokeStatic&quot;,
        &quot;fileName&quot;: &quot;http_client.clj&quot;,
        &quot;lineNumber&quot;: 37,
        &quot;className&quot;: &quot;cognitect.http_client$empty_bbuf&quot;,
        &quot;nativeMethod&quot;: false
      }
   ...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is this a problem with my code? It seems to work when not in a Lambda.&lt;/p&gt;
</description>
<category>Libs</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8363/retrieve-s3-object-from-a-lambda</guid>
<pubDate>Wed, 07 Aug 2019 15:55:48 +0000</pubDate>
</item>
</channel>
</rss>