Trying out Function as a Service — With Google Function
(Because a good hero photo would attract reader at first sign — thanks for photo by Kiwihug on Unsplash)
It’s 2017 and the keyword “serverless”, “ go serverless” or “Function as a service — FasS” is not something strange anymore.
First impression, awesome documentation.
Sure, we would want to “Quick Start”
And I love commandline tool, so …
Yay, step by step instructions:
All given steps above completed.
After installing cloud SDK, make sure gcloud was loaded into your shell environment.
When you initialize your cloud sdk, you will be guided through the process of authentication with your Google Account and authorizing the project to be manipulated with gcloud.
Now create a new project:
mkdir faas-testing-hello-world
with 1index.js
file vim index.js
According to the documentation, we will need to create a BUCKET for deployment.
gsutil mb -p <my-project-id> gs://faas-testing-hello-world
Let’s deploy:
gcloud beta functions deploy newsSources — stage-bucket faas-testing-hello-world — trigger-http
trigger-http
is one of many ways that defined how our function will be invoked. In this case, a http call will trigger this function. This will take a while
Done, your function should be shown up on Function listing
Invoke the function from POSTMAN
That’s it! Now it’s time for your imagination to add more features without worrying about infrastructure, maintenance, scaling, etc.