Enrich a photo album with a serverless application, using Cloud Run & terraform

August 23, 2023

After our daughter was born, we started an album with printed photos. One thing was bothering me, we had a lot of short videos that I wished to put in that album.

I had no other choice than to build a solution to include those videos.

And since I was expecting the service behind it to be used only occasionally, it was the perfect project to learn how to create a serverless architecture from scratch.

The idea was simple, generate a QR Code for a given video, print it and stick it in the album. Then, we scan it with a dedicated application that would automatically play the corresponding video.

Hosting on a Cloud platform

I started building the project around 3 majors parts:

  • a serverless API for uploading videos and mapping QR Codes to media files
  • a React application able to scan QR Codes
  • a storage to host the media files

For the hosting, I hesitated between AWS & GCP. Both plaforms provide the necessary tools for a serverless project.

On AWS, it's a combination of AWS App Runner for running a docker container automatically & S3 for the storage.
On GCP, it's Cloud Run & Cloud Storage.

Since it's not possible yet to scale down automatically to 0 with AWS App Runner, I went with GCP to keep costs down. I don't need to have my API staying idle every day when I'm not using it.

1 domain, 3 services

With some forwarding rules, I created the following structure:

There is a lot of configuration going on to set up those services, so I've used Terraform which is a great Infrastructure as Code tool.

You can find my Terraform configuration on github.

I've also enabled continuous deployment using Github actions and these 2 makefile targets:

The result

I've tested the project with pictures and videos of my cat when she was a kitten.