Codementor Events

Trying out Function as a Service — With Google Function

Published Sep 12, 2017


Photo by Kiwihug on Unsplash

(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.

Google Cloud Functions Documentation | Cloud Functions | Google Cloud Platform
_This is a beta release of Google Cloud Functions. This API might be changed in backward-incompatible ways and is not…_cloud.google.com

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.

Discover and read more posts from Toan Tran The
get started
post commentsBe the first to share your opinion
Show more replies