|
|
|
@ -25,7 +25,9 @@ srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
|
|
|
|
|
|
# shellcheck disable=SC2034,SC2154
|
|
|
|
|
usage_description="
|
|
|
|
|
Lists GCP Cloud SQL instances and their users for each SQL instance in the current GCP Project
|
|
|
|
|
Lists GCP Cloud SQL users for each running SQL instance in the current GCP Project
|
|
|
|
|
|
|
|
|
|
Only works on running instances since it requires querying the DB. We skip non-running instances as otherwise the GCloud SDK errors out
|
|
|
|
|
|
|
|
|
|
Can optionally specify a project id using the first argument, otherwise uses currently configured project
|
|
|
|
|
|
|
|
|
@ -56,13 +58,15 @@ cat <<EOF
|
|
|
|
|
# C l o u d S Q L U s e r s
|
|
|
|
|
# ============================================================================ #
|
|
|
|
|
|
|
|
|
|
# running instances only
|
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
# might need this one instead sqladmin.googleapis.com
|
|
|
|
|
if is_service_enabled sql-component.googleapis.com; then
|
|
|
|
|
while read -r instance; do
|
|
|
|
|
gcp_info "Cloud SQL users for instance '$instance'" gcloud sql users list --instance "$instance"
|
|
|
|
|
done < <(gcloud sql instances list --format='get(name)')
|
|
|
|
|
done < <(gcloud sql instances list --format='get(name)' --filter 'state = RUNNABLE')
|
|
|
|
|
else
|
|
|
|
|
echo "Cloud SQL API (sql-component.googleapis.com) is not enabled, skipping..."
|
|
|
|
|
fi
|
|
|
|
|