Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add secretsmanager wrapper #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

heurtematte
Copy link
Contributor

Allow use of Vault CLI as a replacement for Pass.

sm_read <mount> <path>
sm_write <mount> <path> key1=value1 key2=value2 ...

Including test file: secretsmanager_wrapper_test.sh

Patch example for add_creds.sh

diff --git a/pass/add_creds.sh b/pass/add_creds.sh
index 7bbc16e..3c91eed 100755
--- a/pass/add_creds.sh
+++ b/pass/add_creds.sh
@@ -17,6 +17,7 @@ IFS=$'\n\t'
 SCRIPT_FOLDER="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 source "${SCRIPT_FOLDER}/pass_wrapper.sh"
+source "${SCRIPT_FOLDER}/secretsmanager_wrapper.sh"
 
 _verify_inputs() {
   local project_name="${1:-}"
@@ -40,7 +41,7 @@ _check_pw_does_not_exist() {
   local pw_store_path="bots/${project_name}/${path}"
 
   # check that the entries do not exist yet
-  if passw cbi "${pw_store_path}" &> /dev/null ; then
+  if sm_read "cbi" "$pw_store_path" &> /dev/null ; then
     printf "%s credentials for %s already exist. Skipping creation...\n" "${path}" "${project_name}"
     return 1
   fi
@@ -66,12 +67,8 @@ _add_to_pw_store() {
   local email="${3:-}"
   local user="${4:-}"
   local pw="${5:-}"
-
-  local pw_store_path="bots/${project_name}/${site}"
-
-  echo "${email}" | passw cbi insert --echo "${pw_store_path}/email"
-  echo "${user}" | passw cbi insert --echo "${pw_store_path}/username"
-  echo "${pw}" | passw cbi insert --echo "${pw_store_path}/password"
+  local pw_store_path="${project_name}/${site}"
+  echo "${pw}" | sm_write "cbi" "$pw_store_path" "email=${email}" "username=${user}" "password=-"
 }
 
 _generate_ssh_keys() {
``

Signed-off-by: sebastien.heurtematte <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant