-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset.sh
executable file
·35 lines (30 loc) · 1.55 KB
/
reset.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
PROJECT_ID=<project_id>
DATASET_NAME=vm_observer
REGION=us-central1
gcloud iam service-accounts remove-iam-policy-binding vm-observer-sa@${PROJECT_ID}.iam.gserviceaccount.com \
--member='serviceAccount:vm-observer-sa@${PROJECT_ID}.iam.gserviceaccount.com' \
--role='roles/viewer'
gcloud iam service-accounts remove-iam-policy-binding vm-observer-sa@${PROJECT_ID}.iam.gserviceaccount.com \
--member='serviceAccount:vm-observer-sa@${PROJECT_ID}.iam.gserviceaccount.com' \
--role='roles/bigquery.admin'
gcloud iam service-accounts remove-iam-policy-binding vm-observer-sa@${PROJECT_ID}.iam.gserviceaccount.com \
--member='serviceAccount:vm-observer-sa@${PROJECT_ID}.iam.gserviceaccount.com' \
--role='roles/run.invoker'
gcloud iam service-accounts delete --quiet vm-observer-sa@${PROJECT_ID}.iam.gserviceaccount.com
echo "service account deleted: vm-observer-sa@${PROJECT_ID}.iam.gserviceaccount.com"
bq rm -q -f ${DATASET_NAME}.vm_table_delta
bq rm -q -f ${DATASET_NAME}.vm_table_latest
bq rm -q -f ${DATASET_NAME}.vm_table_ts
bq rm -q -f ${DATASET_NAME}.disk_table_delta
bq rm -q -f ${DATASET_NAME}.disk_table_latest
bq rm -q -f ${DATASET_NAME}.disk_table_ts
bq rm -q -f ${DATASET_NAME}.vm_info
bq rm -d -q -f ${DATASET_NAME}
echo "bigquery dataset deleted: ${DATASET_NAME}"
gcloud scheduler jobs delete daily-vm-collect --quiet
echo "cloud scheduler deleted"
gcloud run services delete vmobserver --region=${REGION} --quiet
echo "cloud run deleted"
gcloud container images delete gcr.io/${PROJECT_ID}/vmobserver --quiet
echo "container registry deleted"