Fork me on GitHub

I wonder if anyone has tried to make use of Terraform provider schemas in Clojure land


So I went and hacked a sample, that reads in provider schemas, and make some additional namespaced keywords to give helpers for typing out resources at the repl:


just a hacky idea, was thinking on how to do somethink like CDK intellisense, but for pure data


and then thought about making all resource blocks/attributes namespaced...


the above doesn't make nested blocks into namespaced keywords though, since keywords have a single namespace only, could maybe make a convention to glue type name + block name as namespace


:thinking_face: isn't the output of cdk pure data anyway?


just that cdk makes kinda this "dsl" to create the data

Karol Wójcik13:09:16

Btw is using CDK makes it really easier/more reliable to provision infrastructure? I have used it several times, but always come back to terraform with huge relief.


and langs that popup stuff in ides after typing a dot after a symbol kinda limit the amout of options to put "data" in


terraform has a cdk also btw


they even use this same jsii magic


but anyhow, that bottoms out on plain tf, you get plan & other normal TF niceties


we run very small and shallow stacks, so pure aws cloudformation has so far been rather sufficient. the only parts where this is annoying is cases where you need stuff like 5 almost identical machines across 3 availability zones. in those cases i feel like cdk would help. after amazon added the import-export of variables it's somewhat usable approach


just thinking that spitting out data is nice in Clojure, there are these odd data spitting libs in other langs (like sceptre for python), CDK goes towards kind of extreme in having data spitting with this jsii thing for many langs, how to get a nice data feel for Clojure, with just some added typing (completion) helpers


anyone have a theory for why cdk-clj didn't take off? @viesti


I was using it, then followed the authors to typescript cdk and the DX was much better. Since it's all side effects, a functional language didn't add much benefit. My guess, they realised it wasn't a good fit and required a lot of maintenance


good summary, though I'd still kinda think that Clojure is pretty neat for generating data, and CloudFormation bottoms out as data (that is consumed by the CloudFormation service itself) and funny thing that only after just now trying to generate Terraform as JSON, the whole HCL mapping to data structures feels kinda nice 🙂 So this got me thinking on a way to make typing the data easier on Clojure side, best would be to have some intellisense that could suggest attribute names and references to other resource attributes, wondering this could partially be solved with fully qualified keywords 🙂


If you just want CF json then this works well


ah yes, have forgotten about that 🙂 There also this edn-to-cfn spike that my colleague did, generates clojure.spec from the CF schema programmatically:


both Terraform and Cloudformation have their "spec" in machine readable format, allows to programmatically generate them


Emacs Cider even has a spec browser to navigate the generated specs


I guess the editor intellisense just wasn't there for Clojure, there's so many resource names and attributes/block per resource that looking up the correct names to spell without any help takes time, at least if you're not familiar with the resources


somewhere along those lines, if I remember correctly from following the #cdk-clj channel back in the day :)


So I thought that could these resource thingies be baked into keywords, bake the context into the keyword namespace+name, so completing & discovery would be easy. The keywords might become kinda long though 🙂 (like :aws_cloudfront_distribution-origin-custom_header/name)


now remembering aws-api Conj presentation and datafy+nav, didn't Stu say that he almost had a navigable aws service api thing at hand? 🙂

Alex Miller (Clojure team)18:09:18

The cognitect aws-api supports datafy/nav and works well with REBL (and David Chelimsky demo'ed that in a different talk at the same conj)

Alex Miller (Clojure team)18:09:48

I'm not sure if that's what you're referring to?


it might be "datafy ARN" that I was trying to remember


Stu's example on look datomic logs, find a thing that looks like an ARN, datafy it and hop onto it, something like that 🙂

Alex Miller (Clojure team)18:09:49

ah, don't know about that