Skip to content

Commit

Permalink
generate url safe password for postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
jcma-google committed Aug 27, 2024
1 parent f52022b commit f37ba89
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cloud/azure/bin/lib/key_vault.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,14 @@ function key_vault::add_generated_secrets() {
shift
for key in "$@"; do
echo "Generating secret: ${key}"
local USECHARSET=$CHARSET
if [[ "${key}" == "postgres-password" ]]; then
echo "Using url safe charset"
USECHARSET=$URL_SAFE
fi
local SECRET_VALUE="$(head /dev/urandom \
| LC_CTYPE=ALL tr -dc "${CHARSET}" \
| LC_CTYPE=ALL cut -c -40)"
| LC_CTYPE=ALL tr -dc "${USECHARSET}" \
| LC_CTYPE=ALL cut -c -40)"
echo "Setting secret: ${key}"
key_vault::add_secret "${VAULT_NAME}" "${key}" "${SECRET_VALUE}"
done
Expand Down

0 comments on commit f37ba89

Please sign in to comment.