|
| 1 | +(ns tailrecursion.boot-stack |
| 2 | + {:boot/export-tasks true} |
| 3 | + (:require |
| 4 | + [boot.core :as boot] |
| 5 | + [boot.pod :as pod] |
| 6 | + [boot.util :as util])) |
| 7 | + |
| 8 | +(def ^:private deps |
| 9 | + '[[cheshire "5.8.1"] |
| 10 | + [com.amazonaws/aws-java-sdk-cloudformation "1.11.419"]]) |
| 11 | + |
| 12 | +(defn- warn-deps [deps] |
| 13 | + (let [conflict (delay (util/warn "Overriding project dependencies, using:\n"))] |
| 14 | + (doseq [dep deps] |
| 15 | + (when (pod/dependency-loaded? dep) |
| 16 | + @conflict |
| 17 | + (util/warn "• %s\n" (pr-str dep)))))) |
| 18 | + |
| 19 | +(defn- pod-env [deps] |
| 20 | + (let [dep-syms (->> deps (map first) set)] |
| 21 | + (warn-deps deps) |
| 22 | + (-> (dissoc pod/env :source-paths) |
| 23 | + (update :dependencies #(remove (comp dep-syms first) %)) |
| 24 | + (update :dependencies into deps)))) |
| 25 | + |
| 26 | +(boot/deftask create |
| 27 | + [n stack NAME str "Name of the stack" |
| 28 | + r region REGION str "AWS Region" |
| 29 | + a access-key ACCESS_KEY str "AWS Access Key" |
| 30 | + s secret-key SECRET_KEY str "AWS Secret Key" |
| 31 | + t template TMPL edn "AWS CloudFormation template."] |
| 32 | + (let [pod (pod/make-pod (pod-env deps))] |
| 33 | + (boot/with-pre-wrap fileset |
| 34 | + (util/info "Creating stack %s in region %s...\n" stack region) |
| 35 | + (pod/with-call-in pod |
| 36 | + (tailrecursion.boot-stack.client/create-stack! ~*opts*)) |
| 37 | + fileset))) |
| 38 | + |
| 39 | +(boot/deftask delete |
| 40 | + [n stack NAME str "Name of the stack" |
| 41 | + r region REGION str "AWS Region" |
| 42 | + a access-key ACCESS_KEY str "AWS Access Key" |
| 43 | + s secret-key SECRET_KEY str "AWS Secret Key"] |
| 44 | + (let [pod (pod/make-pod (pod-env deps))] |
| 45 | + (boot/with-pre-wrap fileset |
| 46 | + (util/info "Deleting stack %s in region %s...\n" stack region) |
| 47 | + (pod/with-call-in pod |
| 48 | + (tailrecursion.boot-stack.client/delete-stack! ~*opts*)) |
| 49 | + fileset))) |
0 commit comments