Fork me on GitHub
#portkey
<
2017-09-08
>
cgrand09:09:11

=> (binding [*credentials* {:access-key "XXXX"
                            :secret-key "YYYY"} 
             *region* "eu-central-1"]
     (lambda/list-functions {}))
[:result {:functions [{:role "arn:aws:iam::238568392557:role/portkey", :description "", :code-size 5826344, :function-arn "arn:aws:lambda:eu-central-1:238568392557:function:user_Iflatter", :dead-letter-config {}, :master-arn nil, :last-modified "2017-07-13T10:08:40.196+0000", :code-sha256 "Nx3nojHfJakr8w5EVS6ZhbGq+vQ6uq0z0BRGBPpcFPg=", :runtime :java8, :memory-size 1536, :vpc-config {}, :environment {}, :tracing-config {:mode :pass-through}, :timeout 30, :version "$LATEST", :kmskey-arn nil, :handler "portkey.LambdaStub", :function-name "user_Iflatter"}], :next-marker nil}]

viesti09:09:47

whoa 🙂

viesti09:09:18

hmm, where’s the tweet? 🙂

viesti09:09:12

:kmskey-arn nil actually brings to my mind that I did’t specify that on function creation/configuration update

viesti09:09:30

since environment variables can be encrypted (passwords etc)

cgrand10:09:24

Ok. Now, unless explicitly dynamically bound, credentials and region are fetched from the same usual locations (env vars, properties, profile files).

cgrand10:09:40

Now it’s just:

=> (require '[portkey.aws.lambda :as lambda])
=> (lambda/list-functions {})
{:functions [{:role "arn:aws:iam::238568392557:role/portkey", :description "", :code-size 5826344, :function-arn "arn:aws:lambda:eu-central-1:238568392557:function:user_Iflatter", :dead-letter-config {}, :master-arn nil, :last-modified "2017-07-13T10:08:40.196+0000", :code-sha256 "Nx3nojHfJakr8w5EVS6ZhbGq+vQ6uq0z0BRGBPpcFPg=", :runtime :java8, :memory-size 1536, :vpc-config {}, :environment {}, :tracing-config {:mode :pass-through}, :timeout 30, :version "$LATEST", :kmskey-arn nil, :handler "portkey.LambdaStub", :function-name "user_Iflatter"}], :next-marker nil}

cgrand10:09:23

aws-clj-sdk can now be tested for the following services (rest-json protocol) “AWS Batch” “AWS Greengrass” “AWS IoT” “AWS IoT Data Plane” “AWS Lambda” “AWS X-Ray” “Amazon API Gateway” “Amazon CloudDirectory” “Amazon CloudSearch Domain” “Amazon Cognito Sync” “Amazon Elastic File System” “Amazon Elastic Transcoder” “Amazon Elasticsearch Service” “Amazon Glacier” “Amazon Lex Model Building Service” “Amazon Lex Runtime Service” “Amazon Pinpoint” “Amazon Polly” “Amazon WorkDocs See example above for a simple invocation. doc doesn’t return a docstring at the moment but at least displays specs:

=> (doc lambda/list-functions)
-------------------------
portkey.aws.lambda/list-functions
([input__8278__auto__])
Spec
  args: (tuple :portkey.aws.lambda/list-functions-request)
  ret: (and :portkey.aws.lambda/list-functions-response)

cgrand14:09:09

the elusive s3v4 signature is v4 + special rules for payalod hashing (unsigned, chunked, normal) and the additional payload hash header

cgrand14:09:43

fun fact: it seems like the root element of xml responses is not specified 🤷

cgrand15:09:17

@richiardiandrea abstracting over json and http client libs.

cgrand15:09:24

There is provision for async support in the current design. By binding http-client one can have functions returning promises or chans instead of values.

cgrand15:09:16

@viesti async was such a low hanging fruit

cgrand15:09:51

=> (binding [aws/*http-client* aws/async-http-client]
     (lambda/list-functions))
#object[clojure.core.async.impl.channels.ManyToManyChannel 0x7975d4aa "clojure.core.async.impl.channels.ManyToManyChannel@7975d4aa"]
=> (async/<!! *1)
[:result {:functions [{:role "arn:aws:iam::238568392557:role/portkey", :description "", :code-size 5826344, :function-arn "arn:aws:lambda:eu-central-1:238568392557:function:user_Iflatter", :dead-letter-config {}, :master-arn nil, :last-modified "2017-07-13T10:08:40.196+0000", :code-sha256 "Nx3nojHfJakr8w5EVS6ZhbGq+vQ6uq0z0BRGBPpcFPg=", :runtime :java8, :memory-size 1536, :vpc-config {}, :environment {}, :tracing-config {:mode :pass-through}, :timeout 30, :version "$LATEST", :kmskey-arn nil, :handler "portkey.LambdaStub", :function-name "user_Iflatter"}], :next-marker nil}]

viesti15:09:34

for some reason was thinking about binding conveyance, but channels fit well

cgrand21:09:47

Bindings are conveyed through go blocks in Clojure (not in Clojurescript obviously)

cgrand21:09:35

If you prefer another async flavor you just have to provide a new http-client

richiardiandrea15:09:05

Very nice, would be super interested in a lumo port given I am using the JS aws SDK quite extensively. So if it's only an abstraction over http, it should be quite easy to achieve that

viesti15:09:05

have to learn to use binding as a choice for structuring a library

cgrand15:09:02

@richiardiandrea I have good hopes that all generated files could be pure cljc.

richiardiandrea16:09:46

@cgrand will explore, thanks everything looks good

viesti16:09:52

awesome work, didn’t image what reach this project would have when we started on it 🙂