Creating Google App Engine Project

This quickstart shows how to deploy a sample app on App Engines.

Before you begin

  1. In the Google Cloud Console, on the project selector page, select or create a Google Cloud project. Go to project selector

  2. Make sure that billing is enabled for your Cloud project. Learn how to check if billing is enabled on a project. Check Billing health checks.

/posts/gcp/creating_google_app_engine_project/001_billing_health_check.png

  1. Enable the Cloud Build API. Go to Cloud Build API

/posts/gcp/creating_google_app_engine_project/002_cloud_build_api.png

4.Install and initialize the Google Cloud CLI. Installing Google Cloud CLI on Ubuntu 20.04.4 LTS

  1. Create an App Engine application for your Cloud project in the Google Cloud Console. Open app creation

  2. Select a region where you want your app’s computing resources located.

Write basic web service with Node.js

GitLab repo

server.js

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
const express = require("express");
const app = express();

app.get("/", (req, res) => {
  res.send("Hello from App Engine!");
});

const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
  console.log(`Server listening on port ${PORT}`);
});

package.json

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
{
  "name": "app-engine-test",
  "version": "1.0.0",
  "description": "App Engine Test",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  },
  "dependencies": {
    "express": "^4.17.3"
  }
}

app.yaml

1
runtime: nodejs14

Deploy your service on App Engine

In your Node.js service folder, where the app.yaml file is located, run the following command in your terminal:

1
gcloud app deploy

If all ok you should see something similar

/posts/gcp/creating_google_app_engine_project/003_deploy.png

The target url is app location. You can use as well the following command:

1
gcloud app browse

You can access web service here