-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeploy.sh
54 lines (42 loc) · 2.12 KB
/
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
if [ -f .env ]; then
export $(cat .env | grep -v '#' | awk '/=/ {print $1}')
fi
gcloud services enable cloudbuild.googleapis.com;
gcloud services enable cloudfunctions.googleapis.com;
gcloud services enable cloudscheduler.googleapis.com;
gcloud services enable secretmanager.googleapis.com;
gcloud iam service-accounts create nwea-map-etl;
gcloud projects add-iam-policy-binding $GOOGLE_CLOUD_PROJECT \
--member="serviceAccount:nwea-map-etl@$GOOGLE_CLOUD_PROJECT.iam.gserviceaccount.com" \
--role=roles/iam.serviceAccountUser;
gcloud projects add-iam-policy-binding $GOOGLE_CLOUD_PROJECT \
--member="serviceAccount:nwea-map-etl@$GOOGLE_CLOUD_PROJECT.iam.gserviceaccount.com" \
--role=roles/cloudfunctions.developer;
gcloud projects add-iam-policy-binding $GOOGLE_CLOUD_PROJECT \
--member="serviceAccount:nwea-map-etl@$GOOGLE_CLOUD_PROJECT.iam.gserviceaccount.com" \
--role=roles/secretmanager.secretAccessor;
gcloud projects add-iam-policy-binding $GOOGLE_CLOUD_PROJECT \
--member="serviceAccount:nwea-map-etl@$GOOGLE_CLOUD_PROJECT.iam.gserviceaccount.com" \
--role=roles/storage.objectAdmin;
printf $NWEA_PASSWORD | gcloud secrets create nwea-map-password --data-file=-;
gsutil mb -p $GOOGLE_CLOUD_PROJECT gs://nwea-map-$GOOGLE_CLOUD_PROJECT;
cd src;
gcloud functions deploy nwea-map-etl \
--project $GOOGLE_CLOUD_PROJECT \
--service-account nwea-map-etl@$GOOGLE_CLOUD_PROJECT.iam.gserviceaccount.com \
--runtime python37 \
--entry-point main \
--trigger-http \
--set-env-vars GCS_BUCKET=nwea-map-$GOOGLE_CLOUD_PROJECT \
--set-env-vars NWEA_USERNAME=$NWEA_USERNAME \
--quiet;
gcloud app create --region=us-central;
gcloud scheduler jobs create http nwea_map_function_trigger \
--schedule "0 5 * * *" \
--time-zone "America/Chicago"\
--uri "https://us-central1-$GOOGLE_CLOUD_PROJECT.cloudfunctions.net/nwea-map-etl" \
--http-method POST \
--oidc-service-account-email [email protected] \
--oidc-token-audience "https://us-central1-$GOOGLE_CLOUD_PROJECT.cloudfunctions.net/nwea-map-etl" \
--project $GOOGLE_CLOUD_PROJECT \
--quiet;