-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgcp_cloud_functions.sh
49 lines (30 loc) · 1.18 KB
/
gcp_cloud_functions.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
#####################################################################################
#
# Google Cloud Functions (Python)
#
# References:
# https://cloud.google.com/functions/docs/
#
#####################################################################################
# ENV Variables
export cloud_func_name=parse_logs
export cloud_storage_bucket_name=gs://zdataset1
# Create Function (which will be uploaded to Google Cloud Functions)
def parse_cdn_log(data, context):
"""
Background Cloud Function to be triggered by Cloud Storage.
Args:
data (dict): The Cloud Functions event payload.
context (google.cloud.functions.Context): Metadata of triggering event.
Returns:
None; the output is written to Stackdriver Logging
"""
# Upload / Deploy function to Google Cloud Functions
# https://cloud.google.com/functions/docs/calling/
gcloud functions deploy $cloud_func_name \
--runtime python37 \
--trigger-resource $cloud_storage_bucket_name \
--trigger-event google.storage.object.finalize
# Delete function from Google Cloud Functions
gcloud functions delete &cloud_func_name
#ZEND