Skip to content

Instantly share code, notes, and snippets.

@mesmacosta
Created December 7, 2020 18:56
Show Gist options
  • Select an option

  • Save mesmacosta/0eca622d5a9ac340812b419dc563f59f to your computer and use it in GitHub Desktop.

Select an option

Save mesmacosta/0eca622d5a9ac340812b419dc563f59f to your computer and use it in GitHub Desktop.
# Set Up the Service Account
# Start by setting your project ID. Replace the placeholder to your project.
gcloud config set project MY_PROJECT_PLACEHOLDER
# Next load it in a environment variable.
export PROJECT_ID=$(gcloud config get-value project)
# Then create a Service Account.
gcloud iam service-accounts create saphana2dc-workload-sa \
--display-name "Service Account for SAP HANA Data Catalog Ingestion" \
--project $PROJECT_ID
# Next create a credentials folder where the Service Account will be saved.
mkdir -p ~/credentials
# Next create and download the Service Account Key.
gcloud iam service-accounts keys create "saphana2dc-workload-sa.json" \
--iam-account "saphana2dc-workload-sa@$PROJECT_ID.iam.gserviceaccount.com" \
&& mv saphana2dc-workload-sa.json ~/credentials/saphana2dc-workload-sa.json
# Next add Data Catalog admin role to the Service Account.
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member "serviceAccount:saphana2dc-workload-sa@$PROJECT_ID.iam.gserviceaccount.com" \
--quiet \
--project $PROJECT_ID \
--role "roles/datacatalog.admin"
# Next set up the credentials environment variable.
export GOOGLE_APPLICATION_CREDENTIALS=~/credentials/saphana2dc-workload-sa.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment