Add aws credential file
This commit is contained in:
parent
5ac161f4d4
commit
c4ce3cd275
2 changed files with 19 additions and 2 deletions
|
@ -2,7 +2,7 @@
|
|||
(:require
|
||||
[orchestra.core :refer [defn-spec]]
|
||||
[clojure.spec.alpha :as s]
|
||||
[clojure.string :as st]))
|
||||
[dda.backup.infrastructure :as i]))
|
||||
|
||||
(def default {:dry-run false
|
||||
:debug false})
|
||||
|
@ -13,6 +13,12 @@
|
|||
::debug
|
||||
::execution-directory]))
|
||||
|
||||
(s/def ::aws-access-key-id string?)
|
||||
(s/def ::aws-secret-access-key string?)
|
||||
(s/def ::aws-config
|
||||
(s/keys :req-un [::aws-access-key-id
|
||||
::aws-secret-access-key]))
|
||||
|
||||
(defn-spec env-or-file string?
|
||||
[name string?]
|
||||
(let [from-env (System/getenv name)
|
||||
|
@ -22,3 +28,14 @@
|
|||
(some? name-from-file) (slurp name-from-file)
|
||||
:else (throw ( RuntimeException.
|
||||
(str "Environment: [" name "," name-from-file "] was missing." ))))))
|
||||
|
||||
|
||||
(defn-spec create-aws-credentials! nil?
|
||||
[config ::aws-config]
|
||||
(let [{:keys [aws-access-key-id aws-secret-access-key]} config]
|
||||
(i/execute! [["mkdir" "/root/.aws"]] {})
|
||||
(spit "/root/.aws/credentials"
|
||||
(str "[default]\n"
|
||||
"aws_access_key_id=" aws-access-key-id "\n"
|
||||
"aws_secret_access_key=" aws-secret-access-key "\n"))
|
||||
(i/execute! [["chmod" "0600" "/root/.aws/credentials"]] {})))
|
|
@ -22,7 +22,7 @@
|
|||
[config ::pg-config]
|
||||
(let [config-w-defaults (merge default config)]
|
||||
(spit "/root/.pgpass" (domain/pgpass config-w-defaults))
|
||||
(i/execute! ["chmod" "0600" "/root/.pgpass"] config)))
|
||||
(i/execute! [["chmod" "0600" "/root/.pgpass"]] config)))
|
||||
|
||||
(defn-spec drop-create-db! nil?
|
||||
[config ::pg-config]
|
||||
|
|
Loading…
Reference in a new issue