Skip to content

Instantly share code, notes, and snippets.

@dbalan
Last active October 21, 2021 11:33
Show Gist options
  • Select an option

  • Save dbalan/af0a587c433458d969d41499dd941147 to your computer and use it in GitHub Desktop.

Select an option

Save dbalan/af0a587c433458d969d41499dd941147 to your computer and use it in GitHub Desktop.
!/usr/bin/env bb
(require '[clojure.java.shell :refer [sh]])
(def expected (get (System/getenv "STAGE")
{ "dev" "12345"
"prod" "123456"}))
(def curr-account
((json/parse-string
((sh "aws" "sts" "get-caller-identity") :out) true) :Account))
(if (= expected curr-account)
(println "stage matches account")
((fn [] (println (format "error: wrong stage for account %s" curr-account))
(System/exit -1))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment