Cloud Functions Flashcards
Cloud Functions - Definition
Serverless computing platform designed to run single-purpose pieces of code in response to events in GCP environments (PaaS)
How are Cloud Functions managed? (3 key points)
- functions execute in a secure isolated environment
- since they each run in a separate instance, they don’t share memory, so they need to be stateless
- multiple instances may be running at once.
How long can a Cloud Function run?
default timeout is 1 min, but can be configured up to 9 min
What languages do Cloud Functions support?
Node.js 8
Node.js 10
Python 3.7
Go 1.1
Cloud Functions - key points (3)
- managed independently from other services
- short running code
- fully managed - serverless
How do cloud functions work?
Events have triggers which executes a function in response to the event.
Examples of Cloud Function events (5)
- HTTP Request
- Cloud Storage event - adding, deleting, etc… a file
- Cloud Pub/Sub event - publishing a message
- Firebase - database trigger
- Stackdriver logging
Cloud Function functions - key points (3)
- run in a separate instance every time they are invoked
- no way to share data without using external service
- the function is passed arguments about the event
Cloud Functions use case examples (4)
- webhooks - respond to an http request
- image processing - validate or transform images
- mobile back end - react to storage, authentication or data event
- IOT - react to pub/sub from devices
What needs to be filled in when creating a cloud function via the cloud console?
- name
- memory allocation - 128MB to 2GB
- trigger
- event type - depends on trigger
- source of function code - editor , zip file , upload, etc…
- runtime - node, python or go
Create cloud function via shell - main command
gcloud functions deploy [NAME]
Cloud function shell parameters (3)
- -trigger-resource or –trigger-topic
- -trigger-event
Command to delete a cloud function via shell?
gcloud functions delete [NAME]