Illuminating Deposits - Google Cloud Platform (GCP) trigger of Resources applied to Golang (Go) Google Cloud Functions (GCF 2nd Generation)
Delta is the approx. value of 30 days Interest for a deposit. So if a deposit is for 10 years the Delta is still calculated for 30 days Interest using the Interest for 10 years to get an approx. value of 30 days Interest. Hence, the variation in interest money in 30 days is called Delta. This value Delta is used to compare as a mechanism to let you know which deposits are performing better for you.
(Development is WIP)
Illuminating Deposits Project Logo:
Created from link:
GREEN here means these initial cloud functions have been implemented, development is in progress. RED Text And GREEN Stroke boxes means partially completed in progress There is only 1 box in RED + GEEN and that is the box for the Google Cloud Function (GCF) gcf_analytics.
---------------------------
gcf_upload google cloud function is triggered by HTTP request and submits HTTP POST request body to google cloud storage bucket for further processing.
Terraform is used to deploy gcf_upload to google cloud. The service account used for deployment needs keys to be generated and stored in the deploy/terraform folder with the file being renamed to keys.json. The gcf_upload is written in Go and uses google cloud storage and google cloud functions.
Add alias tf=terraform in .zshrc or equivalent Steps start from root of project folder
cd gcf_upload
make init
make apply
In the end on successful creation you will get something like:google_cloudfunctions2_function.illuminating_gcf_upload: Creation complete
- Dependent Google cloud functions should be destroyed first. So if you are also working on
gcf_interestcal also for example (see below) then see destruction in gcf_interestcal.
If you are only playing around with this Google cloud function,
after you are done using this function and no longer need for any processing,
make destroy
In the end on successful destruction you will get something like:google_storage_bucket.illuminating_gcf_upload_bucket: Destruction complete
Also, See Related Multiple Cloud Functions
make cloud-incorrect-json
make cloud-not-successful-http-request-accounttypemissing
make cloud-not-successful-http-request-banknamemissing
make cloud-successful-http-request
Steps start from root of project folder
cd gcf_upload
make gcf-local
cd gcf_upload
make local-incorrect-json
make local-not-successful-http-request-accounttypemissing
make local-not-successful-http-request-banknamemissing
make local-successful-http-request
Here this sends Cloud Storage event to a CloudEvent function running at localhost:8080 using curl request.
- Go to Log tab of Google Cloud Function
- Click Log Explorer
- At the bottom Click Edit Time to see logs for the last 15 minutes (even this can be edited to say last 10 minutes) Per the retention period these logs delete after 30 days. There is no charge for the 30-day period. (https://cloud.google.com/logging#section-7)
- Click Refresh button to see the logs Also, See Related Multiple Cloud Functions
To see logs using gcloud command line:
gcloud config set project illuminatingdeposits-gcp
gcloud auth login
sudo pip3 install grpcio
export CLOUDSDK_PYTHON_SITEPACKAGES=1
gcloud alpha logging tail --format="default(timestamp,text_payload)"
---------------------------
gcf_interestcal google cloud function is triggered by upload to illuminating_upload_json_bucket_input by gcf_upload cloud function and starts calculating Delta for each bank account including overall for all deposits. It then also uploads the calculated Deltas with deposit details to illuminating_upload_json_bucket_output google cloud storage bucket for further processing.
Depends on gcf_upload cloud function deployed and having run successfully. See System Diagram for more details.
Terraform is used to deploy gcf_interestcsal to google cloud. The service account used for deployment needs keys to be generated and stored in the deploy/terraform folder with the file being renamed to keys.json. The gcf_interest is written in Go and uses google cloud storage and google cloud functions.
Add alias tf=terraform in .zshrc or equivalent Steps start from root of project folder
cd gcf_interestcal
make init
make apply
In the end on successful creation you will get something like:google_cloudfunctions2_function.illuminating_gcf_interestcal: Creation complete
- After you are done using this function and no longer need for any processing,
make destroy
In the end on successful destruction you will get something like:google_storage_bucket.illuminating_gcf_interestcal_bucket: Destruction complete
Also, See Related Multiple Cloud Functions
make cloud-successful-storage-upload
This copies the file locally to cloud storage
Steps start from root of project folder
cd gcf_interestcal
make gcf-local
make local-successful-send-event-to-cloud-event-function
This only triggers the function locally and does not copy the file to cloud storage.
Here this sends Cloud Storage event to a CloudEvent function running at localhost:8080 using curl request.
---------------------------
gcf_analytics google cloud function is triggered by upload to illuminating_upload_json_bucket_output by gcf_interestcal cloud
function and starts appending the calculations to BigQuery delta_calculations
table in gcfdeltaanalytics
table.
Scope: Analytics triggered by a Submit of Interest Request only supported currently.
Currently,
- This appends a row in BigQuery for Interest Request Submitted. There is also env variable for query only mode to bypass this fpr development mode.
- Based on the interest request submitted, this does query on BigQuery for delta calculations overall for last 5 requests to compare the delta calculations. This result is placed in Analytics struct
- Then it also Publishes as JSON the analytics message to PubSub.
Depends on gcf_interestcal cloud function deployed and having run successfully. See System Diagram for more details.
Add alias tf=terraform in .zshrc or equivalent Steps start from root of project folder
cd gcf_analytics
make init
make apply
- In the end on successful creation you will get something like:
google_cloudfunctions2_function.illuminating_gcf_analytics: Creation complete
- After you are done using this function and no longer need for any processing,
make destroy
In the end on successful destruction you will get something like:google_storage_bucket.illuminating_gcf_analytics_bucket: Destruction complete
Also, See Related Multiple Cloud Functions
make cloud-successful-storage-upload
This copies the file locally to cloud storage
Steps start from root of project folder
cd gcf_analytics
make gcf-local
make local-successful-send-event-to-cloud-event-function
This only triggers the function locally and does not copy the file to cloud storage.
You can send an event to CloudEvent function locally with already existing file in cloud storage
Here this sends Cloud Storage event to a CloudEvent function running at localhost:8080 using curl request.
This Google cloud function is triggered by message published to pubsub topic deltaanalyticstopic
by
gcf_analytics cloud function. Uses google cloud secret manager grabbing sendgrid api key to send email message
decoded from base64 encoding per JSON message schema received from pubsub.
Only sends from verified sender.
Sends to env email address for now, in future version will be able to
send to email address specified in request
Depends on gcf_analytics cloud function deployed and having run successfully. See System Diagram for more details.
Add alias tf=terraform in .zshrc or equivalent Steps start from root of project folder
cd gcf_notify
make init
make apply
- In the end on successful creation you will get something like:
google_cloudfunctions2_function.illuminating_gcf_notify: Creation complete
- After you are done using this function and no longer need for any processing,
make destroy
In the end on successful destruction you will get something like:google_storage_bucket.illuminating_gcf_notify_bucket: Destruction complete
Also, See Related Multiple Cloud Functions
make cloud-pubsub-message-successful
This publishes a message to pubsub topic
Steps start from root of project folder
cd gcf_notify
make gcf-local
make local-successful-send-event-to-cloud-event-function
This triggers the function locally by sending message to deltaanalyticstopic.
Here this sends Cloud Pub/Sub event to a CloudEvent function running at localhost:8080 using curl request.
---------------------------
Add alias tf=terraform in .zshrc or equivalent
Steps start from root of project folder at illuminatingdeposits-gcp-trigger
make init
make apply
make destroy
Since everything gets triggered with gcf_upload, we will test gcf_upload , gcf_interestcal, gcf_analytics and gcf_notify together using gcf_upload http request submission:
cd gcf_upload
make cloud-successful-http-request
- To view logs in Google Cloud Log Explorer for all cloud functions change query tab text to:
(resource.type = "cloud_run_revision" resource.labels.service_name ="illuminating-gcf-upload" OR resource.labels.service_name = "illuminating-gcf-interestcal" OR resource.labels.service_name = "illuminating-gcf-analytics" OR resource.labels.service_name = "illuminating-gcf-notify" resource.labels.location = "us-central1") severity>=DEFAULT
- Click Run Query
- Adjust time to see logs from last 10 minutes or whatever as needed
- You should see in log email sent. This happens after the analytics are calculated and sent to pubsub topic.
- you should receive an email set in env variable
RECEIVER_EMAIL
in gcf_notify cloud function with the custom message.
---------------------------
v0.5.0