Skip to content

Instantly share code, notes, and snippets.

@Intelrunner
Created March 5, 2024 14:22
Show Gist options
  • Save Intelrunner/daf0c501e889eef9b3f887b8f95aa10e to your computer and use it in GitHub Desktop.
Save Intelrunner/daf0c501e889eef9b3f887b8f95aa10e to your computer and use it in GitHub Desktop.
Check all projects in a GCP org to see if an API is enabled.
#!/bin/bash
# The Organization ID (Replace with your organization's ID)
ORG_ID="your-organization-id"
# Gather all projects under the specified organization
PROJECT_IDS=$(gcloud projects list --organization=${ORG_ID} --format="value(projectId)")
# Loop through each project
for PROJECT_ID in ${PROJECT_IDS}; do
echo "Checking project: ${PROJECT_ID}"
# List enabled services and check if BigQuery API is enabled
if gcloud services list --project=${PROJECT_ID} --enabled --format="value(config.name)" | grep -q "bigquery.googleapis.com"; then
echo "BigQuery API is enabled in project: ${PROJECT_ID}"
else
echo "BigQuery API is not enabled in project: ${PROJECT_ID}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment