we talked with @viesti about a common edn->cloudformation transformation
It seems it could just be a mechanical edn->json transformation with camel casing keyword keys… and sprinkling in clojure.specs for keys as needed (or is useful)
is that even something that portkey project wants to include? or perhaps I’m missing a better Clojure solution
it seems a multi-spec based on the resource type would be beneficial (even more so if we could scrape the aws docs and autogenerate specs for the properties of different services)
I think portkey-cloud is a fine place for all things about Clojure conquering the cloud :)
wonder if there are machine readable specs for CF publicly available, and if there's prior art to this direction
I’ll check what the python troposphere does
at least that looks like hand written code https://github.com/cloudtools/troposphere/blob/master/troposphere/ec2.py
I’m suitably lazy that an approach that requires hand writing specs for all of cloudformation is definitely a no-go 😛
a hacky solution might be to just screen scrape the JSON code sample element from the pages https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-listenerrule.html
:thinking_face: just stumbled upon https://github.com/fungusakafungus/cloudformation-jsonschema
looks like there is some machine readable spec https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification.html
I think I’ll try to create a macro that loads that and emits the clojure.spec specs
ah, have faint memory of seeing that region specific spec list
hmm, provides links to documentation, which is nice
it seems easy enough to read&process… and even create constructor functions with documentation scraped from the pages
hmm, there are these !Sub and !Join things, intrinsics I guess are their names in CF lingua
which one uses to, say interpolate the value of a parameter to resource argument (prefixing s3 bucket names comes to my mind as an example)
edn-to-cfn.tools.generate> (resource-spec “AWS::ElasticLoadBalancingV2::Listener” listener)
(clojure.spec.alpha/def
:aws.elastic-load-balancing-v2/listener
(clojure.spec.alpha/keys
:req
[:aws.elastic-load-balancing-v2/default-actions
:aws.elastic-load-balancing-v2/load-balancer-arn
:aws.elastic-load-balancing-v2/port
:aws.elastic-load-balancing-v2/protocol]
:opt
[:aws.elastic-load-balancing-v2/certificates
:aws.elastic-load-balancing-v2/ssl-policy]))
one can use the return value of a resource in a another resource, this is how CF forms dependencies
I’m planning to punt on the CF lingua things, they are easily enough encoded as JSON without any special handling
perhaps provide constructor fns for them to more easily create them
so I've had this Leiningen like (deftemplate...
idea in my head, but might be that it's just hot air
I’m optimistic about this approach, I’m already able to generate the following types of files: https://gist.github.com/tatut/93dda41f40736f9b07088b2658f9f577
I think, it’s better to just provide the edn->cfn
function which the transformation and gives good expound error messages
after some experience in using it, more convenience macros can be added
but enough coding for this friday evening, ttyl 🙂
have a nice weekend! 🙂