Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Build simple a REST API
/ 20
Create a Revision for Cloud Run
/ 20
Create two cloud storage buckets
/ 10
Create a Pub/Sub topic for receiving notification from storage bucket
/ 10
Create a Pub/Sub subscription
/ 10
Create another build for REST API
/ 15
Create a new Revision
/ 15
Build simple a REST API
/ 20
Create a Revision for Cloud Run
/ 20
Create two cloud storage buckets
/ 10
Create a Pub/Sub topic for receiving notification from storage bucket
/ 10
Create a Pub/Sub subscription
/ 10
Create another build for REST API
/ 15
Create a new Revision
/ 15
Twelve years ago, Lily started the Pet Theory chain of veterinary clinics. Pet Theory currently sends invoices in DOCX format to clients, but many clients complain that they cannot open them. To improve customer satisfaction, Lily asks Patrick in IT to investigate an alternative solution.
Pet Theory's Ops team is a single person, so they want to invest in a cost-efficient solution that doesn't require extensive ongoing maintenance. After analyzing the various processing options, Patrick decides to use Cloud Run.
Cloud Run is serverless, so it abstracts away infrastructure management and lets you focus on building your application instead of managing overhead. As a Google Cloud serverless product, Cloud Run can scale to zero, so it doesn't incur charges when not in use. Cloud Run also supports custom binary packages in containers, which makes it straightforward to build consistent, isolated artifacts.
In this lab, you build a PDF converter web app on Cloud Run that automatically converts files stored in Cloud Storage into PDFs stored in separate folders.
The following diagram shows an overview of the services that you use in this lab and how they connect to one another:
In this lab, you learn how to perform the following tasks:
This is an intermediate-level lab that assumes familiarity with the Google Cloud console and shell environments. Experience with Firebase is helpful, but not required. Before taking this lab, complete the following Google Skills labs:
When you're ready, follow the steps in the next section to set up your lab environment.
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the right is the Lab setup and access panel with the following:
Note that the lab timer is located near the top of the page, showing the remaining time.
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab setup and access panel.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab setup and access panel.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud, in Google Cloud, refer to the gcloud CLI overview guide.
Pet Theory wants to convert their invoices into PDFs so that customers can open them reliably. The team wants to perform this conversion automatically to minimize the workload for Lisa, the office manager.
Ruby, Pet Theory's computer consultant, receives a message from Patrick in IT:
|
Patrick, IT Administrator |
Hi Ruby, I've done some research and found that LibreOffice is good at converting many different file formats to PDF. Would it be possible to run LibreOffice in the cloud without having to maintain the servers? Patrick |
|
|
Hey Patrick, I think I have just the thing for this type of situation. I just watched a great video from Next 19 about Cloud Run on YouTube. It looks like we can run LibreOffice in a serverless environment with Cloud Run. No server maintenance is needed! I'll send over some resources that will help you get set up. Ruby |
Help Patrick set up and deploy Cloud Run.
In the Google Cloud console, on the Navigation menu (), click APIs & Services > Library.
In the search bar, type Cloud Run, and then click Cloud Run Admin API in the results list.
If the API isn't already enabled, click Enable, and then click the browser Back button twice.
The Google Cloud console should now resemble the following:
Ruby has developed a Cloud Run prototype and wants Patrick to deploy it on Google Cloud. Help Patrick deploy the PDF Cloud Run service for Pet Theory.
lab03:package.json in Cloud Shell Editor, and in the scripts section, add "start": "node index.js", as shown in the following snippet:Open the lab03/index.js file and review the code.
You deploy the application as a Cloud Run service that accepts HTTP POST requests. If a POST request is a Pub/Sub notification about an uploaded file, the service writes the file details to the log. Otherwise, the service returns the string "OK".
Review the lab03/Dockerfile file.
This Dockerfile manifest provides a recipe for Docker to build an image. Each line begins with an instruction that tells Docker how to process the following information:
node as the base image template to create the container image.npm start.Run the following command to build the container image for the REST API using Cloud Build:
The command builds a container image with your code and stores it in Artifact Registry in your project.
In the Google Cloud console, on the Navigation menu (), click View all products.
For CI/CD, click Artifact Registry > Repositories.
Click the gcr.io repository to view your hosted container image:
Test completed task
Click Check my progress to verify the objective.
When the deployment finishes, the terminal displays a message similar to the following:
$SERVICE_URL environment variable so that you can easily access your service:$SERVICE_URL to verify it:Test completed task
Click Check my progress to verify the objective.
This command returns the error message "Your client does not have permission to get the URL." This error confirms that anonymous users cannot call the service.
If you receive the response "OK", you have successfully deployed the Cloud Run service.
Now that you have deployed the Cloud Run service, Ruby wants Patrick to create a staging area to convert the data. The Cloud Storage bucket uses an event trigger to notify the application when a user uploads a file for processing.
Test completed task
Click Check my progress to verify the objective.
Cloud Storage labels the notifications with the new-doc topic.
Test completed task
Click Check my progress to verify the objective.
pubsub-cloud-run-invoker service account with appropriate scoped permissions. If this command reports that the service account already exists, proceed to the next step.
Locate the project whose ID starts with qwiklabs-gcp-. You use the PROJECT_NUMBER value in the next command:
PROJECT_NUMBER environment variable, replacing [project number] with the project number from the previous command:roles/iam.serviceAccountTokenCreator role for the Pub/Sub service agent. If this command returns an existing binding status, proceed to the next step.
new-doc topic:Test completed task
Click Check my progress to verify the objective.
To verify that the application works as expected, Ruby asks Patrick to upload test data to the Cloud Storage bucket and check Cloud Logging.
After the upload finishes, in the Google Cloud console, on the Navigation menu (), click View all products.
In Observability, click Logging.
In the All resources drop-down menu, select Cloud Run Revision, and then click Apply.
Click Run query.
In Query results, click a log entry that starts with file:.
The entry displays the file metadata that Pub/Sub sends to your Cloud Run service when you upload a new file. Locate the name field in the payload to confirm the uploaded filename:
file:, click Load newer logs.upload bucket:Patrick needs to convert a backlog of invoices to PDFs so that all customers can open them. He emails Ruby for help:
|
Patrick, IT Administrator |
Hi Ruby Based on your findings, I think we can automate this process and also move to using PDF as the invoice format. I spent a bit of time yesterday coding a solution and built a Node.js script to do what we need. Could you take a look? Patrick |
Patrick sends Ruby the code fragment he wrote to produce a PDF from a file:
Ruby responds to Patrick:
|
Ruby, Software Consultant |
Hi Patrick Cloud Run uses containers, so we need to provide your application in this format. For the next step we need to create a Dockerfile manifest for the application. Your code uses LibreOffice. Can you send me the command for installing that software? I will need to include it in the container. Ruby |
|
Patrick, IT Administrator |
Hi Ruby Awesome, here is how I usually install LibreOffice on servers in the office:
Let me know if you need any more information. Patrick |
Building the container requires integrating several components:
With all required files identified, you can update the manifest. Help Ruby configure and deploy the container.
Because the container doesn't yet include the LibreOffice package, you need to add it. Patrick provided the commands to install LibreOffice, and Ruby adds them as a RUN instruction in the Dockerfile.
Dockerfile manifest and add the RUN apt-get update -y && apt-get install -y libreoffice && apt-get clean instruction as shown in the following file:index.js file and add the following package requirements at the top of the file:app.post('/', async (req, res) handler with the following code:index.js file matches the following complete example:index.js file with this example code.The following lines contain the main conversion logic:
Whenever a user uploads a file, Cloud Storage triggers this service, which performs the following tasks in order:
/tmp directory (an in-memory filesystem that behaves like a local disk).process.env.PDF_BUCKET environment variable specifies the target Cloud Storage bucket. You assign a value to this variable when you deploy the service in the next steps.The rest of index.js implements the helper functions that this top-level code calls.
Now you can deploy the updated service, set the PDF_BUCKET environment variable, and allocate 2 GiB of memory for LibreOffice using the --memory option.
Y and press ENTER. Building the container might take a few minutes.Test completed task
Click Check my progress to verify the objective.
With LibreOffice included in the container, this deployment takes longer than the previous one. Wait a few minutes for the deployment to finish.
Click Check my progress to verify the objective.
If you receive the response "OK", you have successfully deployed the updated Cloud Run service. LibreOffice can convert many file formats to PDF, including DOCX, XLSX, JPG, PNG, and GIF.
In the Google Cloud console, on the Navigation menu (), click Cloud Storage > Buckets.
Click the -upload bucket, and then click Refresh several times to observe how the service deletes each file after converting it to a PDF.
In the left navigation pane, click Buckets, and then click the bucket whose name ends in -processed.
Verify that the bucket contains PDF versions of all uploaded files, and open a PDF file to confirm that the service converted it properly.
-processed bucket.Pet Theory now has a system to convert their archive of files to PDFs. When someone uploads files to the -upload bucket, the pdf-converter service converts them and writes the resulting PDFs to the -processed bucket.
Continue your serverless journey in the Serverless Cloud Run Development course. In this course, you read through a fictitious business scenario and assist the characters with their serverless migration plan.
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated November 4, 2026
Lab Last Tested November 4, 2026
Copyright 2026 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We can notify you via email when it becomes available
Great!
We can contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one