This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # adventofcode (30)
- # announcements (51)
- # aws (27)
- # babashka (1)
- # beginners (16)
- # calva (6)
- # cider (10)
- # clj-kondo (2)
- # clojure (94)
- # clojure-dev (27)
- # clojure-italy (1)
- # clojure-taiwan (1)
- # clojure-uk (5)
- # clojurescript (18)
- # clojutre (2)
- # cursive (14)
- # data-science (8)
- # emacs (2)
- # joker (5)
- # off-topic (3)
- # shadow-cljs (31)
- # sql (2)
- # vim (2)
- # yada (11)
Hi everyone, I’m running some CLJS in AWS Lambda, and I’m keen to automate my deployment using either serverless or AWS SAM. I’ve spent some time looking at them, and they both seem to have problems. My current attempt is using serverless, cljs-lambda (which I was already using) and serverless-cljs-plugin. This seems to work ok, except that serverless-cljs-plugin isn’t invoked when using serverless offline.
I’ve tried to patch the plugin to make that happen but I can’t make it work, and there’s very little support available for serverless. Their forums and slack channel are very quiet.
So I looked at AWS SAM, but from what I can tell,
sam build is totally non-extensible, so I can’t even figure out how to make it compile CLJS before packaging.
I’m doing this right now. I’m using the new clj-cdk lib which makes it really easy to upload a shadow-cljs zip as part of a generated cloudformation template. really nice experience
TLDR; it creates an API gateway with a Lambda proxy automatically attached with all the necessary perms etc. In my case they are deployed into a Datomic VPC as well but maybe you don’t need that
I haven’t done CI yet but the sdk CLI “works on my machine” so should go well in a docker container
@ Thanks, that’s very interesting, I hadn’t heard of CDK. I’ll read up on that and let you know if I have questions.
there’s a few rough edges but works really well. I owe them a blog post once I get it fully working but, for now, I’m happy to help a fellow Kiwi
Ok, let me do some reading/watching and playing around, I’ll let you know if I have questions.
Here is a leiningen template I made for creating clojure lambdas with http://serverless.com. You are using clojurescript but it might be helpful anyways: https://github.com/jsyrjala/aws-lambda-serverless with this: https://www.npmjs.com/package/serverless-scriptable-plugin
clj-sdk looks really cool! However here’s yet another (minimal but simple) example how to use
shadow-cljs with Serverless Framework https://github.com/vharmain/serverless-healthcheck
npm run deploy boils down to just
npx shadow-cljs release :lib && npx serverless deploy
I've previously used Terraform to deploy Lambdas, it also has a nice support for uploading the code as zip artifact, based of sha of the file
and you can do other necessary infrastructure configuration with Terraform too (Intelli Idea has nice Terraform support)
of course it depends on how one wants to do things, Terraform is a broad avenue to other IaC too, which might be more than just serverless thing, but comes handy if you end up configuring other infrastructure too :)
Hi Colin, This was our experience (from a couple of years ago so things may have changed). Here's a super short summary. We used SAM. We kept our lambda build separate and published direct to S3 using standard clojurescript build tooling. We produced a separate build artefact for the SAM artefacts also published to a well defined S3 location. For the SAM template we parameterised the lambda location in S3 (based on the version number). So then for deployment we wrote some simple scripts to call cloud formation directly and reference the SAM template and the lambdas we had previously published to S3. We were in quite corporate environment so this gave us a good way to control / separate the build, deployment and promotion between environments. This system worked pretty well for us as the pieces were pretty simple. Main drawbacks with SAM was the fact that it is cloudformation so you suffer the normal issue which is needing to split up your stacks to avoid problems if you need to destroy one. ie If your critical data stores are also wrapped up in the same stack then you could be in for some trouble. This might be a lot more than you were after - but hey maybe some of this is of use depending on your context.
@ that's a fascinating stack. Thanks for sharing, and please share with the channel the blog article if you have time to after you write it