
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 an image with Cloud Build
/ 25
Deploy the PDF converter service
/ 25
Create a service account
/ 25
Confirm the Pub/Sub subscription
/ 25
In this lab, you build a PDF converter web app on Cloud Run, a serverless service, to automatically convert files stored in Google Drive into PDFs stored in segregated Google Drive folders.
You assist the Pet Theory Veterinary practice to automatically convert their invoices into PDFs for customer ease of use.
This lab requires the use of Google APIs. The following APIs have been enabled for you:
Name | API |
---|---|
Cloud Build | cloudbuild.googleapis.com |
Cloud Storage | storage-component.googleapis.com |
Cloud Run Admin | run.googleapis.com |
In this lab, you learn how to perform the following tasks:
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 left is the Lab Details pane with the following:
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 Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
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.
In this task, you get started by downloading the code that's necessary for this lab.
Run the following command in Cloud Shell to activate your lab account:
Run the following command to clone the Pet Theory repository:
Run the following command to change to the correct directory:
You can use Gemini Code Assist in an integrated development environment (IDE) such as Cloud Shell to receive guidance on code or solve problems with your code. Before you can start using Gemini Code Assist, however, you need to enable it.
In the Cloud Shell Editor, navigate to Cloud Code > Help and Feedback > Change Settings.
In the Settings, search for Gemini Code Assist.
Locate and ensure that the checkbox is selected for Geminicodeassist: Enable, and close the Settings.
Click Cloud Code - No Project in the status bar at the bottom of the screen.
Authorize the plugin as instructed. If a project is not automatically selected, click Select a Google Cloud Project, and choose
Verify that your Google Cloud project (
In this task, you create a Go application to process requests. As outlined in the architecture diagram, you intend to integrate Cloud Storage as part of the solution.
In the Cloud Shell Editor's File Explorer, navigate to pet-theory > lab03 > server.go.
Open the server.go
file. This action enables Gemini Code Assist, as indicated by the presence of the icon in the upper-right corner of the editor.
Open the server.go
source code and edit it to match the following:
Click the Gemini Code Assist: Smart Actions icon and select Explain this.
Gemini Code Assist opens a chat pane with the prefilled prompt of Explain this
. In the inline text box of the Code Assist chat, replace the prefilled prompt with the following, and click Send:
The explanation for the code in the server.go
file appears in the Gemini Code Assist chat.
In the Cloud Shell terminal, run the following command to build the application:
The functions called by this top-level code are in source files:
With the application successfully built, you can create the PDF conversion service.
The PDF service uses Cloud Run and Cloud Storage to initiate a process each time a file is uploaded to the designated storage.
To achieve this, you decide to use a common pattern of event notifications together with Cloud Pub/Sub. Doing this enables the application to concentrate only on processing information. Transporting and passing information is performed by other services, which allows you to keep the application simple.
Building the invoice module requires the integration of two components:
Adding the LibreOffice package means it can be used in your application.
In the Open editor, open the existing Dockerfile
manifest and update the file as follows:
Save the updated Dockerfile
.
Click the Gemini Code Assist: Smart Actions icon and select Explain this.
Gemini Code Assist opens a chat pane with the prefilled prompt of Explain this
. In the inline text box of the Code Assist chat, replace the prefilled prompt with the following, and click Send:
The explanation for the code in the Dockerfile
file appears in the Gemini Code Assist chat.
Initiate a rebuild of the pdf-converter
image using Cloud Build:
Click Check my progress to verify that you've performed the above task.
Deploy the updated PDF converter service.
--memory
option.Run the following commands to build the container and deploy it:
Click Check my progress to verify that you've performed this task.
The Cloud Run service has now been deployed successfully. However, you deployed an application that requires the correct permissions to access it.
A service account is a special type of account with access to Google APIs.
This lab uses a service account to access Cloud Run when a Cloud Storage event is processed. Cloud Storage supports a rich set of notifications that can be used to trigger events.
In this task, you update the code to notify the application when a file has been uploaded.
Click the Navigation menu > Cloud Storage, and verify that two buckets have been created. You should see:
Create a Pub/Sub notification to indicate that a new file has been uploaded to the docs bucket ("uploaded"). The notification is labeled with the topic "new-doc".
Expected output:
Create a new service account to trigger the Cloud Run services:
Expected output:
Give the service account permission to invoke the PDF converter service:
Expected output:
Find your project number by running this command:
Enable your project to create Cloud Pub/Sub authentication tokens:
Click Check my progress to verify that you've performed this task.
With the service account created, it can be used to invoke the Cloud Run Service.
Before progressing further, you need to test the deployed service. Since the service requires authentication, testing it helps ensure that it is actually private.
Save the URL of your service in the environment variable $SERVICE_URL:
Display the SERVICE URL:
Make an anonymous GET request to your new service:
Expected output:
"Your client does not have permission to get URL"
.
This is good; you don't want the service to be callable by anonymous users.
Now try invoking the service as an authorized user:
Expected output:
Great work, you have successfully deployed an authenticated Cloud Run service.
To initiate a notification when new content is uploaded to Cloud Storage, add a subscription to your existing Pub/Sub Topic.
Create a Pub/Sub subscription so that the PDF converter runs whenever a message is published to the topic new-doc
:
Expected output:
Click Check my progress to verify that you've performed this task.
Now whenever a file is uploaded, the Pub/Sub subscription interacts with your service account. The service account then initiates your PDF Converter Cloud Run service.
To test the Cloud Run service, use the example files available.
Copy the test files into your upload bucket:
Expected output:
In the Cloud Console, click Cloud Storage > Buckets followed by the bucket name ending in "
Click the Refresh button a few times and see how the files are deleted, one by one, as they are converted to PDFs.
Then click Buckets, followed by the bucket name ending in "
Feel free to open the PDF files to make sure they were properly converted.
Once the upload is done, click Navigation menu > Cloud Run, and click on the pdf-converter service.
Select the LOGS tab and add a filter of "Converting" to see the converted files.
Navigate to Navigation menu > Cloud Storage and open the bucket name ending in "
Excellent work, you have successfully built a new service that creates PDFs from files uploaded to Cloud Storage.
In this lab, you've explored how to convert a Go application into a container, constructed containers utilizing Google Cloud Build, and launched a Cloud Run service.
You've also gained skills in enabling permissions through a service account and leveraging Cloud Storage event processing, all of which are integral to the operation of the PDF converter service that transforms documents into PDFs and stores them in the "processed" bucket.
...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 August 18, 2025
Lab Last Tested August 11, 2025
Copyright 2025 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 will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one