Skip to content

A web application deployment using Terraform for AWS, Azure, and GCP.

License

Notifications You must be signed in to change notification settings

michidk/serverless-webapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverless Web App on AWS, GCP, and Azure using Terraform

This sample application contains full Terraform deployments for the three major cloud platforms, namely: Amazon Web Services (AWS), Microsoft Azure (AZ), and Google Cloud Platform (GCP).

About this Project

The goal of this project is to make those three deployments as homogeneous as possible to be able to compare the differences. Since not all cloud platforms offer the same features and work similarly, the resulting architectures differ slightly. Another aim was to make the deployments self-contained (they deploy the function code and frontend automatically), use only Serverless services as well as move all common parts out of the deployment (shared OpenAPI config and code).

The goals of the Terraform deployments in this project are:

  • Use only Serverless services
  • Use standards like OpenAPI
  • Make the architectures as homogeneous as possible
  • Self-contained / Move common parts out of the deployment

The application itself is a simple text analysis service that comes with a web-based frontend:

A screenshot of the sample web app

Contents

The relevant parts of this repository are:

Folder/File Description
.devcontainer/ The vscode devcontainer for this project
.github/ Reamd resources
.vscode/ vscode settings
aws/ The AWS deployment
azure/ The Azure deployment
common/ Common parts of the deployments
common/api/ The OpenAPI config
common/function/ The code for the FaaS function
common/website/ The static website for the frontend
common/mime-types.json The MIME type definitions for uploads
gcp/ The GCP deployment
justfile The just configuration

Setup

You can start up this project rather quickly using the vscode devcontainers, which are based on Docker.

Using the command runner just, apply the Terraform configuration using just apply <folder>, with aws, gcp or azure as the folder name.

The Architecture

General

The application requires a frontend (a static website) and backend (based on Function as a Service (FaaS) offerings). The frontend needs to be served using a Content Delivery Network (CDN) to improve stability and page speeds. The FaaS function of the backend should sit behind an API Gateway.

Amazon Web Services

The AWS architecture

Azure

The AZ architecture

Caveats

Google Cloud Platform

The GCP architecture

Caveats

  • Google requires a load balancer in front of the CDN, which can get expensive
  • There is no Google-provided domain/certificate for the CDN, so an IPv4 has to be provisioned
  • The Google API Gateway only supports OpenAPI v2, not v3. Therefore the api-spec-converter has te be used to convert the OpenAPI definition (using API-spec-converter --from=openapi_3 --to=swagger_2 --syntax=yaml openapi.yaml).