Last active
August 10, 2023 19:01
-
-
Save knbknb/33ee027ec40ddc011f43dadfceb18c2f to your computer and use it in GitHub Desktop.
gcloud snippets
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
#!/usr/bin/env bash | |
# Description: snippets for gcloud | |
# install gcloud sdk | |
# login | |
# first look | |
gcloud auth list | |
gcloud config list | |
gcloud config list project | |
# enable APIs and services: | |
# here for AI Platform | |
gcloud services enable \ | |
compute.googleapis.com \ | |
iam.googleapis.com \ | |
iamcredentials.googleapis.com \ | |
monitoring.googleapis.com \ | |
logging.googleapis.com \ | |
notebooks.googleapis.com \ | |
aiplatform.googleapis.com \ | |
bigquery.googleapis.com \ | |
artifactregistry.googleapis.com \ | |
cloudbuild.googleapis.com \ | |
container.googleapis.com | |
# Create custom service account: | |
SERVICE_ACCOUNT_ID=vertex-custom-training-sa | |
gcloud iam service-accounts create $SERVICE_ACCOUNT_ID \ | |
--description="A custom service account for Vertex custom training with Tensorboard" \ | |
--display-name="Vertex AI Custom Training" | |
# Grant it access to Cloud Storage for | |
# writing and retrieving Tensorboard logs: | |
PROJECT_ID=$(gcloud config get-value core/project) | |
gcloud projects add-iam-policy-binding $PROJECT_ID \ | |
--member=serviceAccount:$SERVICE_ACCOUNT_ID@$PROJECT_ID.iam.gserviceaccount.com \ | |
--role="roles/storage.admin" | |
# Grant it access to your BigQuery data source to read data | |
# into your TensorFlow model: | |
gcloud projects add-iam-policy-binding $PROJECT_ID \ | |
--member=serviceAccount:$SERVICE_ACCOUNT_ID@$PROJECT_ID.iam.gserviceaccount.com \ | |
--role="roles/bigquery.admin" | |
# Grant it access to Vertex AI for running model training, deployment, and explanation jobs: | |
gcloud projects add-iam-policy-binding $PROJECT_ID \ | |
--member=serviceAccount:$SERVICE_ACCOUNT_ID@$PROJECT_ID.iam.gserviceaccount.com \ | |
--role="roles/aiplatform.user" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment