Last active
March 20, 2025 13:14
-
-
Save mpaloni/4c4d90b49d63957fcf1ecb5c6f8c0edd to your computer and use it in GitHub Desktop.
gcloud cli
This file contains 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
gcloud config configurations create my-profile | |
gcloud config set account [email protected] | |
gcloud config configurations list | |
gcloud config configurations activate my-profile | |
gcloud auth application-default login |
This file contains 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
from google.cloud import bigquery | |
# Authenticate with the service account JSON key | |
client = bigquery.Client.from_service_account_json("./service-account.json") | |
# Define the query | |
query = """ | |
SELECT | |
table_catalog AS project_id, | |
table_schema AS dataset_name, | |
table_name | |
FROM `project.dataset.INFORMATION_SCHEMA.TABLES` | |
ORDER BY dataset_name, table_name; | |
""" | |
# Run the query | |
query_job = client.query(query,location="europe-north1") | |
results = query_job.result() | |
# Print the results | |
for row in results: | |
print(row) |
This file contains 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
# Check metadata | |
import requests | |
metadata_url = "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/email" | |
headers = {"Metadata-Flavor": "Google"} | |
response = requests.get(metadata_url, headers=headers) | |
print(f"Service Account Email: {response.text}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment