Last active
October 21, 2021 11:33
-
-
Save dbalan/af0a587c433458d969d41499dd941147 to your computer and use it in GitHub Desktop.
Revisions
-
dbalan revised this gist
Oct 21, 2021 . 1 changed file with 21 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ (require '[babashka.process :as p] '[cheshire.core :as json]) (defn main [] (let [accounts {"dev" "12345" "prod" "123456"} expected (get (System/getenv "STAGE") accounts) curr-account (-> (p/sh "aws sts get-caller-identity") p/check ; aborts if non-zero exit :out (json/parse-string true) :Account)] (if (= expected curr-account) (println "stage matches account") (do (println (str "error: wrong stage for account " curr-account)) (System/exit -1))))) (when (= *file* (System/getProperty "babashka.file")) ; same as python's if __name__ == "__main__" (main)) -
dbalan created this gist
Oct 21, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ !/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))))