-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathdestroy_build.yaml
61 lines (57 loc) · 1.51 KB
/
destroy_build.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
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
steps:
- id: "destroy iot devices"
name: "gcr.io/cloud-builders/gcloud"
entrypoint: "bash"
args:
- "-c"
- |
for i in {1..3}
do
device_id=$(gcloud iot devices list --registry=iot-registry --region=us-central1 | grep -v "^ID" | head -n 1 | awk '{print $2}')
gcloud iot devices delete "$device_id" --registry=iot-registry --region=us-central1 --quiet
done || exit 0
- id: "download encrypted secrets only during build"
name: "gcr.io/cloud-builders/gsutil"
args:
[
"cp",
"gs://$PROJECT_ID-secure-bucket-secrets/ciphertext_file.enc",
"ciphertext_file.enc",
]
- id: "decrypt secrets only during build"
name: gcr.io/cloud-builders/gcloud
args:
[
"kms",
"decrypt",
"--ciphertext-file",
"ciphertext_file.enc",
"--plaintext-file",
"service_account.json",
"--location",
"global",
"--keyring",
"$PROJECT_ID-keyring",
"--key",
"$PROJECT_ID-key",
]
###############################################
# destroy terraform infrastructure
- id: "tf init"
name: "hashicorp/terraform:0.12.9"
entrypoint: "sh"
args:
- "-c"
- |
cd tf_modules/
terraform init
# [START tf-destroy]
- id: "tf destroy"
name: "hashicorp/terraform:0.12.9"
entrypoint: "sh"
args:
- "-c"
- |
cd tf_modules/
terraform destroy -auto-approve
# [END tf-destroy]