Looding...
overview

AI Applications • June 15, 2021

Creating Multiple Applications and Domains in Google App Engine

Businesses are building applications on the cloud to create opportunities and accelerate transformation while ensuring security, accessibility, and scalability. A suitable cloud computing platform is required to create these applications. Google App Engine is one such technology that allows you to build and host scalable web applications on a fully managed serverless platform.

The creation of multiple applications and domains in App Engine enables you to deploy multiple applications to a completely managed and serverless environment. It allows you to deploy directly from code and assign custom domain names to each application individually.

How to Create Multiple Applications and Domains

To understand the creation of multiple applications and domains in App Engine, let’s assume that there are five applications that have been developed. The applications are written in Go, Java, Node, PHP, and Python, which is the main application. These applications need to be deployed in GCP's PaaS offering, App Engine.

Additionally, for these applications, two domain names have been purchased:

  • medium-appengine-domain1.tk
  • medium-appengine-domain2.ml

And these subdomains need to be assigned to individual applications:

  • www.medium-appengine-domain1.tk
  • medium-appengine-domain1.tk
  • go-app.medium-appengine-domain1.tk
  • node-app.medium-appengine-domain2.ml
  • java-app.medium-appengine-domain2.ml
  • php-app.medium-appengine-domain2.ml

So, how can we achieve this?

Implementation of Applications

Deployment

Let's first take a quick look into how we deploy these five applications to App Engine.

App Engine App and Service Organization

In App Engine, we can create a single Application per project. This Application needs to be created in a specific region, which cannot be modified later. App Engine has Services to deploy multiple applications and codebases.

We can deploy multiple apps with their configurations as individual services in App Engine. Each service has its specific URL by which we can use to access it. By default, the default service is created when we deploy for the first time.

Some sample codes and steps to deploy them as services can be found here.

The service names created using the sample code:

  1. default
  2. node
  3. go
  4. java
  5. php

Note that the service names can be alphanumeric strings.

Once the apps are deployed, they are available on these URLs:

Default service: https://<project_id>.<region_id>.r.appspot.com

Individual services: https://<service-name>-dot-<project_id>.<region_id>.r.appspot.com

Custom Domains Setup

With the apps now deployed as individual services, we have individual URLs where we can access these apps. However, we need to set up custom domains that can be used to route to specific services as well. Access to the DNS provider would be required for these steps.

Steps to add custom domain names for App Engine:

  • Go to the GCP Console.
  • Go to App Engine > Settings > Custom Domains.
  • Click on Add a custom domain.
  • If you don’t have a verified domain already, you’ll need to verify your domain first.
  • Enter your domain name, and click on Verify.
  • In the webmaster console, select your Domain Provider. A text string would be displayed. This text string needs to be added as a TXT record in your DNS.
    • Once the DNS record is added and propagated, click on Verify.
  • Once the Verification is done, go back to the App Engine Custom Domains tab, and click on Refresh Domains. If prompted, click on Continue.
  • Here, we enter the fully qualified domain names that our App Engine application requires.
  • Once the domain names are added, click on Save Mappings. Wait till the status for the domains turns green.
  • Once the status is green, click on Continue.
  • You would now get a list of records that need to be added to your DNS. Once added, click on Done.

This process needs to be done for all the URLs that are mentioned at the start of this article. Once all the URLs are added, the screen appears in the below manner in the App Engine Custom Domain section:

You may also see a small loading icon, which shows that the Google Managed SSL certificates are being provisioned.

When the DNS changes are done successfully, the new URLs become accessible on HTTP. Test out all the URLs with HTTP.

You will notice that all the URLs point to the same default service.

To map each URL to a specific service, we will use a file called dispatch.yaml

The dispatch.yaml file is used to override the default request routing mechanism for App Engine. We can provide a map of specific URL patterns, and which service they need to be routed to.

The dispatch.yaml file for this example appears as given below:

dispatch:
- url: "www.medium-appengine-domain1.tk/*"
 service: default
- url: "medium-appengine-domain1.tk/*"
 service: default
- url: "go-app.medium-appengine-domain1.tk/*"
 service: go
- url: "node-app.medium-appengine-domain2.ml/*"
 service: node
- url: "java-app.medium-appengine-domain2.ml/*"
 service: java
- url: "php-app.medium-appengine-domain2.ml/*"
 service: php

We can deploy this file using the following command:

gcloud app deploy dispatch.yaml

Once this file is deployed, you can now test the URLs. They will be routed to specific services.

Important Points:

  • DNS changes would take some time to propagate, depending upon the TTL settings for your DNS records.
  • If your DNS provider has a proxy mechanism for your DNS records, make sure that this proxy mechanism is disabled for all Google App Engine records.
  • Finally, Google will issue SSL certificates for all the custom domains added. However, the SSL certificates would only be provisioned successfully once the DNS changes have been completed. Thus, this process may take a long time to complete.

The creation of multiple applications and domains in App Engine provides us access to a completely managed infrastructure which is highly scalable and elastic. It also enables us to deploy applications developed in multiple programming languages without additional effort. The App Engine gives an infrastructure that manages the applications while ensuring network security and scalability.

Get in touch with us to build your cloud strategy and explore how Google App Engine can enhance your business capabilities.

Written by

Srinibas Misra

Thank you for reaching out to us!

Our experts will be in touch with you shortly.

In the meantime, explore our insightful blogs and case studies.

Something went wrong!

Please try it again.

Share