Deploying to Google Cloud App Engine

30 minutes
  • 6 Learning Objectives

About this Hands-on Lab

Google Cloud App Engine provides a solid, easy-to-access platform for a wide range of web apps. Its interoperability with other Google Cloud services, such as Cloud Storage, enhance its effectiveness. In this hands-on lab, we’ll deploy an app to App Engine that allows users to upload photos and enter details into a NoSQL database, Cloud Datastore. The process requires that we set up a Cloud Storage bucket initially and then customize the `config.py` file before deploying the app.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Enable Cloud Datastore APIs and create a Cloud Storage bucket.
  1. From the main console navigation, go to APIs and Services > Library.
  2. Search for Datastore.
  3. Select the Cloud Datastore API card.
  4. Click Enable, if displayed.
  5. Repeat steps 1-4 twice more to enable the App Engine Admin and Cloud Build APIs.
  6. From the main console navigation, choose Cloud Storage.
  7. Click Create bucket.
  8. Name the bucket uniquely and click Continue.
  9. From the Location Type options, select Region and, in the Location field, select us-central1.
  10. Click Create.
Make the bucket contents public.
  1. Return to the Cloud Storage main Browser page.
  2. Expand the More (3 dots) menu for the new bucket, at the far right of the entry.
  3. Choose Edit bucket permissions.
  4. When the Info panel is displayed, click Add Principal.
  5. In the New principals field, enter allUsers.
  6. Click into the Select a role field, scroll down to Cloud Storage and select Storage Object Viewer.
  7. Click Save and confirm that you want to allow public access when prompted.
Clone GitHub repository.
  1. From the Cloud Shell, issue the following command to clone the repository for this course:

    git clone https://github.com/linuxacademy/content-gcpro-developer
  2. Change directories to content-gcpro-developer/app-engine-lab-2/.

Configure `config.py` file.
  1. Activate the Cloud Shell by clicking its icon in the top row.

  2. If the Cloud Shell does not display the current project ID in yellow, open the Project panel by clicking the project name in the upper-left.

  3. Copy the current project ID.

  4. In the Cloud Shell, enter the following command:

    gcloud config set project <PROJECT_ID>
  5. Click Open Editor.

  6. Expand the content-gcpro-developer folder and then the app-engine-labs sub-folder.

  7. Open config.py.

  8. On line 35, change PROJECT_ID to the current project, as shown in the Cloud Shell.

  9. On line 93, change CLOUD_STORAGE_BUCKET to name of the bucket previously created.

  10. Save the file.

Deploy the app.
  1. In the Cloud Shell, deploy your app with the following code:
    gcloud app deploy
  2. When prompted, choose the same region as the bucket created for the lab.
  3. When prompted, enter Y to continue.
Test the app.
  1. In the Cloud Shell, enter the code:
    gcloud app browse
  2. If the browser window does not open, click the generated link.
  3. When the app appears in the browser, click Add Artwork and complete the subsequent form to test the app.

Additional Resources

You’ve been asked to deploy the latest version of your company’s new app, GuruGiftArt, on Google Cloud App Engine. The app allows a user to enter details about a work of art, including the name of both the artist and the work, as well as a photo — all of which will be publicly viewable. To accomplish this, the app stores data in Cloud Datastore and images in Cloud Storage. The app is written in Python 3 and uses App Engine’s flexible environment.

You’ll need to accomplish the following steps to complete your task:

  1. Ensure that required APIs are available.
  2. Create a Cloud Storage bucket with the proper permissions.
  3. Clone a GitHub repo to acquire the files.
  4. Properly configure the application by modifying a YAML file.
  5. Deploy the app to App Engine in the proper region.
  6. Test the app.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?