Fork me on GitHub
#portkey
<
2018-04-20
>
tatut16:04:35

we talked with @viesti about a common edn->cloudformation transformation

tatut16:04:00

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)

tatut16:04:54

is that even something that portkey project wants to include? or perhaps I’m missing a better Clojure solution

tatut16:04:04

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)

viesti16:04:38

I think portkey-cloud is a fine place for all things about Clojure conquering the cloud :)

viesti16:04:46

wonder if there are machine readable specs for CF publicly available, and if there's prior art to this direction

tatut16:04:07

I’ll check what the python troposphere does

tatut16:04:15

I’m suitably lazy that an approach that requires hand writing specs for all of cloudformation is definitely a no-go 😛

tatut16:04:09

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

tatut17:04:15

I think I’ll try to create a macro that loads that and emits the clojure.spec specs

viesti17:04:28

ah, have faint memory of seeing that region specific spec list

viesti17:04:52

hmm, provides links to documentation, which is nice

tatut17:04:55

it seems easy enough to read&process… and even create constructor functions with documentation scraped from the pages

viesti17:04:11

hmm, there are these !Sub and !Join things, intrinsics I guess are their names in CF lingua

viesti17:04:33

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)

tatut17:04:19

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]))

parrot 4
viesti17:04:22

one can use the return value of a resource in a another resource, this is how CF forms dependencies

tatut17:04:52

I’m planning to punt on the CF lingua things, they are easily enough encoded as JSON without any special handling

tatut17:04:22

perhaps provide constructor fns for them to more easily create them

viesti18:04:38

so I've had this Leiningen like (deftemplate... idea in my head, but might be that it's just hot air

tatut18:04:38

I’m optimistic about this approach, I’m already able to generate the following types of files: https://gist.github.com/tatut/93dda41f40736f9b07088b2658f9f577

tatut18:04:39

I think, it’s better to just provide the edn->cfn function which the transformation and gives good expound error messages

👍 4
tatut18:04:01

after some experience in using it, more convenience macros can be added

tatut18:04:33

but enough coding for this friday evening, ttyl 🙂

viesti19:04:07

have a nice weekend! 🙂