portkey

Portkey: from REPL to Serverless in one call
tatut 2018-04-20T16:14:35.000414Z

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

tatut 2018-04-20T16:17:00.000216Z

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)

tatut 2018-04-20T16:17:54.000653Z

https://imgur.com/a/y4S0VJl

tatut 2018-04-20T16:18:54.000145Z

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

tatut 2018-04-20T16:22:04.000070Z

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)

viesti 2018-04-20T16:48:38.000345Z

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

viesti 2018-04-20T16:51:46.000048Z

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

tatut 2018-04-20T16:52:07.000702Z

I’ll check what the python troposphere does

tatut 2018-04-20T16:52:53.000352Z

at least that looks like hand written code https://github.com/cloudtools/troposphere/blob/master/troposphere/ec2.py

tatut 2018-04-20T16:54:15.000103Z

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

tatut 2018-04-20T16:58:09.000535Z

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

tatut 2018-04-20T16:59:34.000216Z

:thinking_face: just stumbled upon https://github.com/fungusakafungus/cloudformation-jsonschema

tatut 2018-04-20T17:00:33.000659Z

looks like there is some machine readable spec https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification.html

tatut 2018-04-20T17:01:15.000349Z

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

viesti 2018-04-20T17:23:28.000018Z

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

viesti 2018-04-20T17:23:52.000573Z

hmm, provides links to documentation, which is nice

tatut 2018-04-20T17:30:55.000185Z

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

viesti 2018-04-20T17:32:11.000739Z

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

viesti 2018-04-20T17:34:33.000203Z

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)

tatut 2018-04-20T17:35:19.000061Z

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

🦜 1
viesti 2018-04-20T17:35:22.000505Z

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

tatut 2018-04-20T17:36:52.000083Z

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

tatut 2018-04-20T17:37:22.000547Z

perhaps provide constructor fns for them to more easily create them

viesti 2018-04-20T18:25:38.000038Z

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

tatut 2018-04-20T18:33:38.000562Z

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

tatut 2018-04-20T18:34:39.000274Z

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

👍 1
tatut 2018-04-20T18:35:01.000480Z

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

tatut 2018-04-20T18:37:33.000190Z

but enough coding for this friday evening, ttyl 🙂

viesti 2018-04-20T19:16:07.000675Z

have a nice weekend! 🙂

2018-04-20T20:29:30.000235Z

2018-04-20T20:30:30.000383Z