GCP
Google Cloud Platform has a free-tier, with free credits that are easy to qualify for.
Login to Google account
You’ll need a personal Google account to use the Google Cloud Platform. Do not use your umich email address. The following steps are adapted from Google Cloud’s Quickstart using a Linux VM, though they have been adapted to the course.
Create project
Go to the Google Cloud Platform Project Selector page
and create a project. Click AGREE AND CONTINUE
if you agreed to Google’s Terms of Service.
Create a project by clicking on the Create Project
button.
Give your project a name unique to you and click Create
.
Add billing
After selecting your newly created project, the side menu may have additional items pre-pinned, however the two items we need Billing
and Compute Engine
are easily identifiable. Please consult the teaching staff if you couldn’t find any
menu items referenced in this spec.
Click billing
to add a billing method to your project.
When you fill out your billing information, select “individual” as account type. Make sure you see something like this:
Add a credit or debit card. If your back end qualifies for free-tier (it should), this card will not be charged. Select START MY FREE TRIAL
. Return to the project console.
Enable Compute Engine API
Visit GCP’s Compute Engine API site
and select ENABLE
.
Prepare SSH keys
Before creating the VM instance, we’ll set up SSH keys for secure access. The back-end specs in this course will assume that you have a user with username “ubuntu” created on your instance.
The specs further assume that you’re doing all your back-end work, building your server, under user “ubuntu”.
You’re free to build under a different username, e.g., your Google account name, however you will then have to map
between the instructions in the specs and your setup. More importantly, we will NOT be able to help
you should you need help debugging your back-end server. To build your back end as user ubuntu
, please do the following:
Windows on WSL
If you prefer to run Ubuntu shell instead of Windows’ PowerShell, on Ubuntu’s terminal create /etc/wsl.conf
:
laptop$ sudo vi /etc/wsl.conf
and put the following content in it:
[automount]
options = "metadata"
Exit all Ubuntu shells such that Ubuntu is not running and its icon is not showing in your dock (or sign out and sign back in to your Windows account), restart your Ubuntu terminal, and continue with the steps below.
To access your Windows folder from your WSL shell:
# 👇👇👇👇👇👇👇👇👇👇👇👇👇
laptop$ ls /mnt/c/Users/YOUR_WINDOWS_USERNAME/
First generate a public/private key pair for user “ubuntu” in a safe place you can easily remember, for example YOUR*LABS*FOLDER
.:
# 👇👇👇👇👇👇👇👇👇👇
laptop$ cd YOUR*LABS*FOLDER
laptop$ ssh-keygen -C ubuntu
when ssh-keygen
prompts you for the file in which to save the key, enter “reactive.pem”. It will then
prompt you for a passphrase. Leave it empty. Hit return
or enter
, twice. Your identification (private key) would
have been saved in reactive.pem
and your public key in reactive.pem.pub
. You can view the content of
your public key for posting to Google below by:
laptop$ cat reactive.pem.pub
Add SSH keys to project metadata
Go to GCP Metadata page
Open the SSH KEYS
tab and click EDIT
.
On the edit page, click + ADD ITEM
, copy and paste the content of your “reactive.pub” to the empty box that
+ ADD ITEM
brought up, and hit the blue SAVE
button. The content should be something that start with ssh-ed
and end with your username (e.g. ubuntu
).
Your SSH KEYS
tab should now list “ubuntu” under Username
with its corresponding public key:
Configure firewall rules
Next set up the firewall to allow us to test the web server we’ll be setting up later.
Go to VPC network Firewall page and click the Create firewall rule
.
On the Create a firewall rule
dialog box, scroll down to “Targets”. Enter http-server
into the “Target tags” field. Enter 0.0.0.0/0
into the “Source IPv4 ranges” field. Check TCP
and enter 8000
into the “Ports” field.
Click CREATE
.
Create VM instance
Now we’re ready to create the VM instance. Return to the console. Navigate to Compute Engine
> VM Instances
.
Select CREATE INSTANCE
.
Choose instance
As discussed in the “Hosting cost” section of the
spec, for this course, we assume you are running a free-tier backend and will provide
only instructions to set up a free-tier backend, which can only run the tinyllama
LLM model. If you want to run other LLM models,
choose the VM instance with enough resources to host your model of choice. You would
have to pay for VM instances with more resources.
Review the free tier options at the Google Cloud Free Program page
by scrolling to the section titled “Free Tier usage limits”. Look under the “Compute Engine”
section and check regions eligible for free tier. Free tier usage is governed by time used.
Currently, an e2-micro
in Oregon, Iowa, or South Carolina is eligible for free tier if used
for the number of hours in a month.
Give the instance a name and carefully select the regions that are available as free tier
with an e2-micro
configuration.
Configure boot disk
On the left menu, click on OS and storage
, and click the Change
button.
On the Boot disk
page, in the “Operating system” field choose Ubuntu
.
In the “Version” field, choose Ubuntu 24.04 LTS
for x86/64
. In “Boot disk type”, be sure to select Standard persistent disk. Any other Boot disk type option will be extra charge!. For the “Size” field, choose 30 GB, which is the
maximum free disk size.
Click SELECT
.
Configure firewall and networking
On the left menu, below OS and storage
, click Networking
. In the Firewall
section, check both Allow HTTP traffic
and Allow HTTPS traffic
.
Startup script
At the bottom of the left menu, click Advanced
. Navigate to the Automation section and find Startup script.
Set up a 4GB swapfile so that your server can survive load spikes. Paste the following script:
#! /usr/bin/env bash
fallocate -l 4G /swapfile # free -h to see allocated size
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
Create the instance
Review all your settings:
- Name and region
- Machine type: e2-micro
- Boot disk: Ubuntu 24.04 LTS, Standard persistent disk, 30GB
- Firewall: HTTP and HTTPS allowed
- Network tags: http-server
- Startup script added
Finally, click Create
at the very bottom of the page to create your VM instance. Wait for the instance to initialize.
When the loading animations are done, write down the external IP address shown on
the screen. In the remainder of this spec, and actually, in all other tutorials
of the course, we will refer to your “external IP” as YOUR_SERVER_IP
.
You’ll never need the internal IP (and GCP doesn’t provide any public DNS for your instance).
ssh to instance
To ssh
to your GCP instance as user “ubuntu” using your private key, reactive.pem
, you must first set its permissions to read-only. In the following, YOUR_SERVER_IP
always refers to the external IP address you’ve noted down earlier.
laptop$ chmod 400 reactive.pem
laptop$ ssh -i reactive.pem ubuntu@YOUR_SERVER_IP
# 👆👆👆👆👆👆👆👆👆
Windows on PowerShell
[Thanks to Jad B. ‘F21 for use of icacls
]
PS laptop> icacls reactive.pem /grant "$($env:username):(r)" /inheritance:r
PS laptop> ssh -i reactive.pem ubuntu@YOUR_SERVER_IP
# 👆👆👆👆👆👆👆👆👆
WARNING Students have reported issues trying to run the course backend on VSCode Server or JetBrains Remote Development Gateway. These are meant for maintaining your source files remotely; they may not be set up for long-running services. Always
ssh
directly to your server as described in this section to run your server.
Persistent swapfile
To mount the 4G swapfile
we created above persistently after each reboot, do:
server$ sudo su
server# echo '/swapfile none swap sw 0 0' >> /etc/fstab
server# exit
Stop instance
DO NOT STOP YOUR INSTANCE. Please leave your e2
instance running for grading purposes. Stopping your instance will change its alloted IP address and undo some of the customizations you’ve done following this spec. When we’re done with all the labs, after the last lab has been graded, in about 2.5 months, and if you don’t need your instance for your course project, then you can stop your instance, to avoid using your GCP credits.
GCP should have given you the minimum of 90 days and $300 of credit upon signing up. That is, if your E2 runs more than 3 months and is not eligible for free tier after that (this should not happen anyways) you will get billed a small amount.
Stop instance **ONLY AT END OF TERM**
Head to your VM instance dashboard. Select your instance and click STOP
.
When you are completely done with your VM instance, delete it to ensure you are not charged. Select your instance and click DELETE
.
Prepared by Luke Wassink, Mark Wassink, Nowrin Mohamed, Chenglin Li, Xin Jie ‘Joyce’ Liu, Yibo Pi, and Sugih Jamin | Last updated July 29th, 2025 |