This repository has been archived by the owner on May 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
tidying-up.sh
executable file
·70 lines (52 loc) · 1.97 KB
/
tidying-up.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
# set -e
#### GLOBAL GCP VARIABLES ####
ACCOUNT=$(gcloud config get-value core/account)
PROJECT=$(gcloud config get-value core/project)
REGION=$(gcloud config get-value compute/region)
GCE_ZONE=$(gcloud config get-value compute/zone)
CLUSTER_NAME="airflow"
DATABASE_INSTANCE_NAME="airflow"
SERVICE_ACCOUNT_NAME=airflowcloudsql
CLOUDSQL_ROLE='roles/cloudsql.admin'
STORAGE_ROLE='roles/storage.admin'
NFS_DEPLOYMENT_NAME=dags-airflow
CLOUD_FILESTORE_INSTANCE=airflow
CLOUD_FILESTORE_LOCATION=europe-west1-b
PROJECT=icabbi-test-210421
for i in "$@"
do
case ${i} in
-project=*|--project=*)
PROJECT="${i#*=}"
;;
-region=*|--region=*)
REGION="${i#*=}"
;;
-gce_zone=*|--gce_zone=*)
GCE_ZONE="${i#*=}"
;;
-database_instance_name=*|--database_instance_name=*)
DATABASE_INSTANCE_NAME="${i#*=}"
;;
esac
done
GCE_LOG_BUCKET_NAME=$PROJECT-airflow
SERVICE_ACCOUNT_FULL=$SERVICE_ACCOUNT_NAME@$PROJECT.iam.gserviceaccount.com
gcloud sql instances delete $DATABASE_INSTANCE_NAME --project=$PROJECT --async --quiet
gcloud container clusters delete $CLUSTER_NAME --project=$PROJECT --zone=$GCE_ZONE --async --quiet
gcloud iam service-accounts delete $SERVICE_ACCOUNT_NAME@$PROJECT.iam.gserviceaccount.com --quiet
gsutil rm -r gs://$PROJECT-airflow
gcloud beta filestore instances delete $CLOUD_FILESTORE_INSTANCE \
--location=$CLOUD_FILESTORE_LOCATION \
--project=$PROJECT
### Permission denied, so had to do this in the dashboard
gcloud iam service-accounts remove-iam-policy-binding $SERVICE_ACCOUNT_FULL \
--project=$PROJECT \
--member=serviceAccount:$SERVICE_ACCOUNT_FULL \
--role=$CLOUDSQL_ROLE --quiet
gcloud iam service-accounts remove-iam-policy-binding $SERVICE_ACCOUNT_FULL \
--project=$PROJECT \
--member=serviceAccount:$SERVICE_ACCOUNT_FULL \
--role=$STORAGE_ROLE --quiet
gcloud deployment-manager deployments delete $NFS_DEPLOYMENT_NAME