Fork me on GitHub
#aws
<
2021-09-26
>
viesti12:09:29

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

viesti12:09:07

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: https://github.com/viesti/clj-tf

viesti12:09:49

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

viesti12:09:13

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

viesti12:09:17

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

kulminaator12:09:53

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

viesti13:09:15

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.

viesti13:09:28

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

viesti13:09:48

terraform has a cdk also btw

viesti13:09:11

they even use this same jsii magic

viesti13:09:24

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

kulminaator13:09:53

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

viesti13:09:38

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

ghadi17:09:32

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

steveb8n11:09:02

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

viesti12:09:00

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 🙂

steveb8n21:09:53

If you just want CF json then this works well https://github.com/brabster/crucible

viesti05:09:35

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: https://github.com/portkey-cloud/edn-to-cfn

viesti05:09:46

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

viesti05:09:54

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

viesti17:09:56

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

viesti17:09:31

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

viesti18:09:43

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)

viesti18:09:06

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? 🙂

alexmiller18: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)

alexmiller18:09:48

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

viesti18:09:32

it might be "datafy ARN" that I was trying to remember https://youtu.be/ppDtDP0Rntw?t=2639

viesti18:09:29

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

alexmiller18:09:49

ah, don't know about that