From 258766f1d9689813c6e07419ee9cc8753c6b52a8 Mon Sep 17 00:00:00 2001 From: Aadhyaaa Mashru Date: Sun, 22 Sep 2024 21:46:02 -0700 Subject: [PATCH 1/2] Modify setup_secrets.sh to use hcp instead of vlt --- setup_secrets.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup_secrets.sh b/setup_secrets.sh index a8acc7a..0c0d578 100755 --- a/setup_secrets.sh +++ b/setup_secrets.sh @@ -5,13 +5,13 @@ ENV_FILE=".env" # Login to Vault echo "Logging into Vault..." -vlt login +hcp auth login if [ $? -ne 0 ]; then echo "Failed to login to Vault. Please check your credentials." exit 1 fi -vlt config init +hcp profile init # Check if .env file exists and delete it if it does if [ -f "$ENV_FILE" ]; then @@ -19,7 +19,7 @@ if [ -f "$ENV_FILE" ]; then fi # Fetch all secret keys from Vault -SECRET_KEYS=$(vlt secrets list -format=json | grep -Eo '"([^"]*)"\s*:\s*"([^"]*)"' | sed -E 's/^"([^"]*)"\s*:\s*"([^"]*)"$/\1=\2/' | grep "^name=" | grep -v "@" | sed 's/^name=//') +SECRET_KEYS=$(hcp vault-secrets secrets list --format=json | grep -Eo '"([^"]*)"\s*:\s*"([^"]*)"' | sed -E 's/"([^"]+)": "([^"]+)"/\1=\2/g' | grep "^name=" | grep -v "@" | sed 's/^name=//') if [ $? -ne 0 ] || [ -z "$SECRET_KEYS" ]; then echo "Failed to retrieve secret keys from Vault." @@ -28,7 +28,7 @@ fi # Iterate over each secret key and fetch the secret value for key in $SECRET_KEYS; do - SECRET_VALUE=$(vlt secrets get --plaintext $key 2>/dev/null) + SECRET_VALUE=$(hcp vault-secrets secrets open $key | grep "Value:" | sed -E 's/Value:\s*(.*)/\1/; s/^[ \t]+|[ \t]+$//g' 2>/dev/null) if [ $? -ne 0 ] || [ -z "$SECRET_VALUE" ]; then echo "Failed to retrieve secret for key $key. Skipping." From 937dadec1d23fbbca401fd650fa87c69ad1f2847 Mon Sep 17 00:00:00 2001 From: Chinemerem Date: Sun, 22 Sep 2024 22:30:16 -0700 Subject: [PATCH 2/2] Update README with hcp --- README.md | 4 ++-- setup_secrets.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2ef41d1..1e774c2 100644 --- a/README.md +++ b/README.md @@ -39,13 +39,13 @@ npm install - In the folder where you cloned the Sistema repository, log into Vault ```bash -vlt login +hcp auth login ``` - Configure the Vault Command Line Interface ```bash -vlt config init +hcp profile init ``` - Select the `sistema` Organization and Project diff --git a/setup_secrets.sh b/setup_secrets.sh index 0c0d578..a42e167 100755 --- a/setup_secrets.sh +++ b/setup_secrets.sh @@ -5,13 +5,13 @@ ENV_FILE=".env" # Login to Vault echo "Logging into Vault..." -hcp auth login +hcp auth login if [ $? -ne 0 ]; then echo "Failed to login to Vault. Please check your credentials." exit 1 fi -hcp profile init +hcp profile init # Check if .env file exists and delete it if it does if [ -f "$ENV_FILE" ]; then