Terraforming Datomic Cloud

If you’re happily using Terraform to spin up your globally-distributed, fault-tolerant, horizontally-scaleable infrastructure you’ll most likely be aware of, and maybe even have used the CloudFormation stack resource.

To provision Datomic Cloud there are a few parameters you need to set. The values for which we can find in the JSON CloudFormation templates provided by the Datomic team.

If we take a recently released CloudFormation template URL we can see how CloudFormation works. Because the Content-Type is set to binary/octet-stream ob-http won’t be able to cut and splice as usual.

GET https://s3.amazonaws.com/datomic-cloud-1/cft/732-8992/datomic-storage-732-8992.json
jq '.Metadata."AWS::CloudFormation::Interface".ParameterLabels'
{
  "Restart": {
    "default": "Reuse Existing Storage"
  },
  "VpcCidrBlock": {
    "default": "VPC CIDR block"
  },
  "Subnet0CidrBlock": {
    "default": "First Subnet CIDR Block "
  },
  "Subnet1CidrBlock": {
    "default": "Second Subnet CIDR Block"
  },
  "Subnet2CidrBlock": {
    "default": "Third Subnet CIDR Block"
  }
}

That’s cool and all. But this is cooler.

(ns script
  (:require
   [babashka.curl :as curl]
   [cheshire.core :as json]
   [clojure.java.io :as io]))

(def url
  "https://s3.amazonaws.com/datomic-cloud-1/cft/732-8992/datomic-storage-732-8992.json")

(def json
  (json/parse-stream (io/reader (:body (curl/get url {:as :stream})))))

(into []
      (map (juxt key #(get (val %) "default")))
      (get-in json ["Metadata"
                    "AWS::CloudFormation::Interface"
                    "ParameterLabels"]))
Restart Reuse Existing Storage
VpcCidrBlock VPC CIDR block
Subnet0CidrBlock First Subnet CIDR Block
Subnet1CidrBlock Second Subnet CIDR Block
Subnet2CidrBlock Third Subnet CIDR Block