Skip to content

Instantly share code, notes, and snippets.

@joshkh
Created October 15, 2020 13:17
Show Gist options
  • Save joshkh/3455a6905517a814b4623d01925baf0e to your computer and use it in GitHub Desktop.
Save joshkh/3455a6905517a814b4623d01925baf0e to your computer and use it in GitHub Desktop.
Deploy Ions to AWS
(ns app.deploy
(:require
[datomic.ion.dev :as dev]
[taoensso.timbre :refer [infof]]))
(defn check-status-loop [{arn :execution-arn :as args}]
(let [{:keys [deploy-status code-deploy-status] :as status}
(dev/deploy-status {:op :deploy-status
:execution-arn arn})]
(if (contains? (set [deploy-status code-deploy-status]) "RUNNING")
(do
(infof "Deployment in progress...")
@(future (Thread/sleep 3000) (check-status-loop args)))
status)))
(defn push []
(dev/push {:op :push}))
(defn deploy [{:keys [rev deploy-groups]}]
(let [execution-arns (for [group deploy-groups]
(dev/deploy {:op :deploy
:group group
:rev rev}))]
(let [deployment-results (map check-status-loop execution-arns)]
(doall (map (fn [r] (infof "Deployment Complete: %s" r)) deployment-results))
(System/exit 0))))
(defn -main [& [deploy-group]]
(infof "Pushing to Code Deploy")
(let [{:keys [rev deploy-groups dependency-conflicts] :as push-result} (push)]
(infof "Deploying revision %s" rev)
(deploy (assoc push-result :deploy-groups [deploy-group]))))
{:alises {:deploy-to-aws {:main-opts ["-m" "app.deploy"]
:extra-deps {com.datomic/ion-dev {:mvn/version "0.9.265"}}}}}
@joshkh
Copy link
Author

joshkh commented Oct 15, 2020

Run from the command line:

$ clj -Adeploy-to-aws some-target-group

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment