-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudbuild.yaml
72 lines (63 loc) · 2.84 KB
/
cloudbuild.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
62
63
64
65
66
67
68
69
70
71
72
steps:
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
entrypoint: "bash"
args:
- "-c"
- |
echo "✅ Creando temas de Pub/Sub..."
gcloud pubsub topics create start-compute || echo "El tema start-compute ya existe"
gcloud pubsub topics create stop-compute || echo "El tema stop-compute ya existe"
echo "✅ Desplegando start_compute_instance..."
gcloud functions deploy start_compute_instance \
--runtime python310 \
--trigger-topic start-compute \
--entry-point start_compute_instance \
--region=northamerica-northeast2 \
--source=./start-aclimate-instance \
--set-secrets=PROJECT_ID=GCP_PROJECT_ID:latest,ZONE=GCP_ZONE:latest,INSTANCE_NAME=GCP_INSTANCE_NAME:latest \
--no-allow-unauthenticated
echo "✅ Desplegando stop_compute_instance..."
gcloud functions deploy stop_compute_instance \
--runtime python310 \
--trigger-topic stop-compute \
--entry-point stop_compute_instance \
--region=northamerica-northeast2 \
--source=./stop-aclimate-instance \
--set-secrets=PROJECT_ID=GCP_PROJECT_ID:latest,ZONE=GCP_ZONE:latest,INSTANCE_NAME=GCP_INSTANCE_NAME:latest \
--no-allow-unauthenticated
echo "✅ Creando Cloud Schedulers..."
# Scheduler para iniciar la instancia el día 5 de cada mes a las 2 AM
gcloud scheduler jobs create pubsub start-compute-5 \
--schedule="0 1 5 * *" \
--time-zone="America/Bogota" \
--topic=start-compute \
--message-body="{}" \
--location=northamerica-northeast1 || \
echo "El Scheduler ya existe"
# Scheduler para iniciar la instancia el día 15 de cada mes a las 2 AM
gcloud scheduler jobs create pubsub start-compute-15 \
--schedule="0 1 15 * *" \
--time-zone="America/Bogota" \
--topic=start-compute \
--message-body="{}" \
--location=northamerica-northeast1 || \
echo "El Scheduler ya existe"
# Scheduler para apagar la instancia el día 7 de cada mes a las 11 PM
gcloud scheduler jobs create pubsub stop-compute-7 \
--schedule="0 23 7 * *" \
--time-zone="America/Bogota" \
--topic=stop-compute \
--message-body="{}" \
--location=northamerica-northeast1 || \
echo "El Scheduler ya existe"
# Scheduler para apagar la instancia el día 20 de cada mes a las 11 PM
gcloud scheduler jobs create pubsub stop-compute-20 \
--schedule="0 23 20 * *" \
--time-zone="America/Bogota" \
--topic=stop-compute \
--message-body="{}" \
--location=northamerica-northeast1 || \
echo "El Scheduler ya existe"
timeout: 1200s
options:
logging: CLOUD_LOGGING_ONLY