Fork me on GitHub
#datomic
<
2018-10-10
>
mping12:10:50

is there a way of retrieving a set of entities grouped by a certain key?

mping13:10:00

I know I can use a custom aggr function

mping13:10:28

gonna give it a try

ro614:10:28

How are people handling middleware with Ions since routing happens at the API Gateway layer?

Joe Lane14:10:08

Nothing stops you from using ring middleware with ions. put the middleware around your app inside your call to apigw/ionize

ro614:10:26

@joe.lane That's what I was thinking, but then aren't I wrapping each handler individually, even if they all share common middleware?

Joe Lane14:10:39

make 1 handler

Joe Lane14:10:46

do your routing in your app

ro614:10:54

Oh, so just a bare API Gateway proxy on "/", then everything the same as a usual Clojure webapp from there?

Joe Lane14:10:11

it can be, if you want to build it that way.

Joe Lane14:10:37

I havent done it that way so I may be wrong, but that is my understanding.

ro614:10:42

Well, I don't want to duplicate routing at two layers....

ro614:10:12

Delegating everything to the app feels like a misuse of API Gateway, but I'm just getting started with this entire stack. I'm basically here asking for best practices, or stories of pain so I can avoid. Maybe those haven't really congealed around Ions yet.

eoliphant15:10:04

Have 'ionized' 3 apps at this point, run every thing through a single API GW for two of them, and the last we have two for a 'hard' separation of user and admin functions. I've been back and forth on it as well, but I'm leaning more towards using APIGW, more or less like ions use lambda, more of an AWS'ey way to 'lift' stuff into the clojure/datomic world as early as possible in a given flow, then just take it from there.

šŸ‘ 4
ro615:10:12

Thanks for the response. I feel much more comfortable drawing from at least some experience rather than making it up as I go. Just to clarify, you mean two "routes" in APIGW mapped to two Ion handlers?

stijn17:10:00

we went with one proxy resource on / in apigw too, we're migrating from datomic cloud client on elasticbeanstalk, so this was a question of get it working with the least rework.

4
stijn17:10:46

maybe one day, i'll try to separate the routing, but then it still makes sense to do that in clojure and use something like bidi to generate the swagger for api gw

eoliphant23:10:50

hey @U8LN9KT2N yep, two separate ion/lambda handlers, and actually 2 separate endpoints, as opposed to 2 routes in a single endpoint. That was Probably more laziness than anything else lol. But may look at doing the routing in a single APIGW at some point

ro615:10:22

I'm definitely drawn to the "one APIGW entry proxying to one Ion handler per app" approach since then I can reuse the established Clojure webapp patterns and track all my routing/etc.. in code rather than a separate structure versioned in AWS. I've been second-guessing though since the core team's tutorials (eg https://docs.datomic.com/cloud/ions/ions-tutorial.html#webapp) guide towards "one Gateway entry and Ion handler per operation".

jocrau15:10:44

How can I grant a lambda ion read access to an S3 object?

Joe Lane15:10:15

Create a policy in IAM with read access to said S3 object, copy the arn for that policy, then do a parameter upgrade on your datomic cloud stack. At the bottom of the first ( I think) page there is a section that says effectively ā€œattach the arn for the policy you want these nodes to haveā€. Paste the arn of the policy you created, complete the parameter upgrade, and that should do it.

Joe Lane15:10:38

(Just did this yesterday on the 4th project we have with ions)

jocrau15:10:37

That worked. Thanks! For reference: My basic misconception was that I added an inline policy to the Lambda execution role. But the Lambda function created on is just a thin layer for invoking the Clojure code inside the Datomic compute node.

jocrau15:10:55

(@stuarthalloway talks about this about 21 minutes into his intro video https://www.youtube.com/watch?v=3BRO-Xb32Ic)

Joe Lane16:10:36

Yeah, the docs are correct, however I believe that part is buried in ā€œOperation > Access Controlā€ no where near the rest of the ion tutorial. https://docs.datomic.com/cloud/operation/access-control.html#authorize-ions