Created
March 27, 2024 14:20
-
-
Save juffaz/da9027b801010d8e16bcd75cbff30529 to your computer and use it in GitHub Desktop.
vault-policy-search-secret.sh
This file contains 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 characters
#!/bin/bash | |
DATABASES=("db/postdb" "db/camunda" "secret/mydb") | |
read_policy() { | |
local policy_name=$1 | |
local policy_content=$(vault policy read $policy_name) | |
echo "$policy_content" | while read -r line; do | |
for database in "${DATABASES[@]}"; do | |
if [[ $line == *"$database"* ]]; then | |
echo "Policy $policy_name found database: $database" | |
break | |
fi | |
done | |
done | |
} | |
policies=$(vault policy list) | |
for policy_name in $policies; do | |
read_policy $policy_name | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment