-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGCP_deploy.sh
executable file
·65 lines (46 loc) · 1.95 KB
/
GCP_deploy.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
#!/usr/bin/env bash
# Load config
source ./config/config.vars
# Load secrets
source ./secrets/secrets.vars
BASE_DIR=`pwd`
echo "Now we are goint to execute gcloud auth login. You will need to manually log in into your GCP account"
read -p "Press ENTER to continue ************************"
# Login if you are not already logged
gcloud auth login
# Create the project (it will fail if it is created)
gcloud projects create $GCP_PROJECT_ID
echo "At this point you should enter into the GCP webconsole, select project $GCP_PROJECT_ID and:"
echo "- Activate billing"
echo "- Activate cloud functions billing, and cloud functions API"
read -p "Press ENTER to continue ************************"
# Set the current project ID
gcloud config set project $GCP_PROJECT_ID
# Create BIGQUERY dataset
# TODO: It promts to select the default project, but tre project is alredy specified in the command (GCP bug?)
GCP_DATASET_EXPIRATION_STR=""
if [[ "$GCP_DATASET_EXPIRATION_S" -ne 0 ]]; then
GCP_DATASET_EXPIRATION_STR="--default_table_expiration $GCP_DATASET_EXPIRATION_S"
fi
bq --location=$GCP_BIGQUERY_LOCATION mk --dataset $GCP_DATASET_EXPIRATION_STR --description "Data for CCU calculation" $GCP_PROJECT_ID:$GCP_DATASET
# Create a BIGQUERY table for heartbeats and add schema
bq mk --table --description "Table for the heartbeats beacons" $GCP_PROJECT_ID:$GCP_DATASET.$GCP_TABLE ./config/table-schema.json
# Deploy collector app
cd $BASE_DIR/collector
./GCP_deploy_collector.sh
# Create cloud function for the API
cd $BASE_DIR/cf-api
./GCP_deploy_api.sh
# Create cloud function for BQ to DS data aggregation
cd $BASE_DIR/cf-dataaggr
./GCP_deploy_dataaggr.sh
# Create cloud function for BQ data expiration (cleanup)
cd $BASE_DIR/cf-databqexp
./GCP_deploy_databqexp.sh
# Deploy clouf function scheduler
cd $BASE_DIR/cron-cloudfunctions
./GCP_deploy_cron_cloudfunctions.sh
# Create DS index
gcloud datastore create-indexes ./config/ds/index.yaml --quiet
# Back to the origin
cd $BASE_DIR