Created
March 5, 2024 14:22
-
-
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.
This file contains hidden or 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 | |
# 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