Skip to content

Instantly share code, notes, and snippets.

@Intelrunner
Created March 5, 2024 14:22
Show Gist options
  • Select an option

  • Save Intelrunner/daf0c501e889eef9b3f887b8f95aa10e to your computer and use it in GitHub Desktop.

Select an option

Save Intelrunner/daf0c501e889eef9b3f887b8f95aa10e to your computer and use it in GitHub Desktop.

Revisions

  1. Intelrunner created this gist Mar 5, 2024.
    18 changes: 18 additions & 0 deletions bq_check.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/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