Deploying a serverless env in minutes with GCP

Laurent Picard
Google Cloud - Community
3 min readMar 22, 2017

Once the GCP account is set up (see previously), only a few additional minutes are needed to launch a serverless app from an actual production environment.

Select App Engine
Let’s choose Python but this can also be Node.js, Java, PHP, Go or Ruby
Select the region representative to your audience
The environment is ready in less than a minute
From here, you can follow the interactive tutorial or try a different approach as follows

The interactive tutorial, if followed, will clone a source repository. Willing to start from scratch with a minimal approach, I cancelled the interactive tutorial to follow the “Quickstart for Python App Engine Standard Environment” tutorial. This cannot be more simple. It consists in the following:

  • Install and initialize the “Google Cloud SDK”
  • Get the python-docs-samples/appengine/standard/hello_world sample code (2 files needed, see below)
  • Test the app locally (open http://localhost:8080/)
  • Deploy the app

Only 2 Files Needed for a Minimal App

  • main.py (Python source code)
  • app.yaml (deployment file)

Test Locally

$ dev_appserver.py app.yaml
INFO 2017-03-20 21:36:53,313 devappserver2.py:764] Skipping SDK update check.
INFO 2017-03-20 21:36:53,361 api_server.py:268] Starting API server at: http://localhost:59317
INFO 2017-03-20 21:36:53,375 dispatcher.py:199] Starting module "default" running at: http://localhost:8080
INFO 2017-03-20 21:36:53,375 admin_server.py:116] Starting admin server at: http://localhost:8000
INFO 2017-03-20 21:39:20,387 module.py:806] default: "GET / HTTP/1.1" 200 13

Deploy to Production

$ gcloud app deployYou are about to deploy the following services:
- majestic-gizmo-162110/default/... (from [...app.yaml])
Deploying to URL: [https://majestic-gizmo-162110.appspot.com]
Do you want to continue (Y/n)? YBeginning deployment of service [default]...
File upload done.
Updating service [default]...done.
Deployed service [default] to [https://majestic-gizmo-162110.appspot.com]
You can stream logs from the command line by running:
$ gcloud app logs tail -s default
To view your application in the web browser run:
$ gcloud app browse

Billing Status

From the moment the app is deployed, the billing status shows estimated costs.

Level Complete!

  • This is as simple as it can be. Deploying a serverless app from scratch to production is a matter of minutes.
  • To avoid using unnecessary resources (and potentially being charged for them), delete the test project (see “Clean up” in the tutorial)
  • This was too easy. Let’s develop an app that actually does something…

Next…

Building a serverless Python app in minutes with GCP

--

--

Laurent Picard
Google Cloud - Community

Tech lover, passionate about software, hardware, science and anything shaping the future • ⛅ explorer at Google • Opinions my own