Google Cloud Quickstart – App Engine

API AutoFlow may be deployed on Google App Engine using its custom flex container deployment support. Google App Engine is designed to support pre-configured/pre-compiled services at scale, so API AutoFlow configuration has to be performed separately prior to deployment.

Custom Flex container deployment on Google App Engine is based on creating a Docker container configuration in Dockerfile. Deployment of API AutoFlow on Google App Engine will use the public API AutoFlow docker image.

There are some requirements for successfully deploying API AutoFlow on Google App Engine

  • Correct License and install information file (license.json). Incorrect License information will result in the service not coming up
  • Preconfigured API AutoFlow configuration file (config.json) with HTTP server configured to service on port 8080
  • Sufficient resources (Depending on the complexity of the solution, you may need to adjust the resource configuration of the app). 2G recommended.

Steps for deploying API AutoFlow on Google App Engine are as follows

  1. Create a new project and Create a new application (Generic to GAE)
  2. Download SDK and Initialize gcloud environment (Generic to GAE)
  3. Deploy API AutoFlow and its configuration

Create a new project and application #

A new project may be created using Google Cloud Console

Go to App Engine Console to create a new application.

Click on Get started

Download Cloud SDK and Initialize environment #

Click on [Download the Cloud SDK] button and follow the instructions. 

Once downloaded, type the following command to initialize the environment.

$ gcloud init

Deploy API AutoFlow and its configuration #

Sample deployment files may be found at

Files are structured in the following manner

app.yaml is required by Google App Engine. Default memory allocation may not be sufficient to run API AutoFlow and the solution. While API AutoFlow normally requires less than 100MB, recommended resource configuration is 2GB.

runtime: custom
env: flex
  cpu: 2
  memory_gb: 2

autoflow.conf defines how API AutoFlow is loaded. This file should not be changed unless API AutoFlow configuration is located elsewhere.

NAME=Google App Engine Instance

config.json is API AutoFlow solution configuration. Configuration can be downloaded from API AutoFlow UI’s [Settings | OAuth] lefthand navigation and clicking on [Download Configuration] button. Google App Engine expects solutions to be serviced through port 8080, so API AutoFlow server has to be configured with port 8080.

Dockerfile defines the application instance. This file should not be changed.

FROM interactor/api-autoflow:nostart
USER root
ADD . /app/data
RUN ["chmod", "+x", "/app/data/"]
ENTRYPOINT ["/app/data/"] starts API AutoFlow and ensures the instance stays alive. This file should not be changed.

/app/bin/api_interactor start
while true; do sleep 30; done;

license.json contains license and install information for API AutoFlow. This file can be copied from API AutoFlow’s data directory.

  "install-id": 1,
  "install-key": "ZZZZZZZZZ",
  "license-id": "XXXXXXXXX",
  "license-key": "YYYYYYYYYYY"

Create a target folder (“app-engine” in the above case) then under the target folder, create the files either by downloading it from and modifying them or by manually creating them.

Under the target folder, issue the following command to deploy API AutoFlow

$ gcloud app deploy --quiet

Validate #

Check the deployment by typing following command

$ gcloud app describe

Command should output something like below

  splitHealthChecks: true
  useContainerOptimizedOs: true
id: api-autoflow-deployment
locationId: us-west2
name: apps/api-autoflow-deployment
servingStatus: SERVING

Use “defaultHostname” information from above to  test the solution. Using above example,

$ curl

Above command should return whatever response API AutoFlow has been configured to return.

Troubleshoot #

Status code 502 returned

502 Bad Gateway may be returned when service is tested using a HTTP request (e.g. curl). This may be caused by 

  • Instance going down due to Lack of memory
  • API AutoFlow HTTP server not being up due to incorrect license information
  • API AutoFlow HTTP server not being up due to incorrect server configuration. Need to be configured on port 8080

If API AutoFlow configuration has been successfully tested before being deployed on Google App Engine, try to increase memory resource allocation in app.yaml file.

Leave a Reply