forked from GoogleCloudPlatform/ai-on-gke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudbuild_delete.yaml
30 lines (30 loc) · 1.32 KB
/
cloudbuild_delete.yaml
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
steps:
- id: Destroy AI on GKE provisioned resources
name: gcr.io/cloudshell-images/cloudshell:latest
env:
- "PLATFORM_VAR_FILE=${_PLATFORM_VAR_FILE}"
- "WORKLOADS_VAR_FILE=${_WORKLOADS_VAR_FILE}"
script: |
#!/usr/bin/env bash
if [ -n ${PLATFORM_VAR_FILE} ] && [ -n ${WORKLOADS_VAR_FILE} ]
then
echo "Variables set OK!"
if [ -f ./platform/${PLATFORM_VAR_FILE} ] && [ -f ./workloads/${WORKLOADS_VAR_FILE} ]
then
echo "Variables files found! Destroying..."
apt-get install google-cloud-sdk-gke-gcloud-auth-plugin -y
terraform -chdir="./workloads/" init -no-color
terraform -chdir="./workloads/" destroy -auto-approve -no-color -var-file ${WORKLOADS_VAR_FILE}
terraform -chdir="./platform/" init -no-color
terraform -chdir="./platform/" destroy -auto-approve -no-color -var-file $PLATFORM_VAR_FILE
else
echo "Variables files not found!" ./platform/${PLATFORM_VAR_FILE} "or" ./workloads/${WORKLOADS_VAR_FILE}
fi
else
echo "Variables PLATFORM_VAR_FILE or WORKLOADS_VAR_FILE are missing."
fi
serviceAccount: 'projects/$PROJECT_ID/serviceAccounts/aiongke@$PROJECT_ID.iam.gserviceaccount.com'
options:
logging: CLOUD_LOGGING_ONLY
dynamicSubstitutions: true
substitutionOption: 'ALLOW_LOOSE'