Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/michidk/serverless-webapp
A web application deployment using Terraform for AWS, Azure, and GCP.
https://github.com/michidk/serverless-webapp
aws azure cloud gcp hacktoberfest serverless terraform
Last synced: 11 days ago
JSON representation
A web application deployment using Terraform for AWS, Azure, and GCP.
- Host: GitHub
- URL: https://github.com/michidk/serverless-webapp
- Owner: michidk
- License: mit
- Created: 2022-04-19T10:42:59.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-26T10:53:33.000Z (8 months ago)
- Last Synced: 2024-10-11T09:50:58.745Z (27 days ago)
- Topics: aws, azure, cloud, gcp, hacktoberfest, serverless, terraform
- Language: HCL
- Homepage:
- Size: 136 KB
- Stars: 7
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Serverless Web App on AWS, GCP, and Azure using Terraform
===This sample application contains full [Terraform](https://terraform.io/) deployments for the [three major cloud platforms](https://www.statista.com/chart/18819/worldwide-market-share-of-leading-cloud-infrastructure-service-providers/), namely: [Amazon Web Services (AWS)](https://aws.amazon.com/), [Microsoft Azure (AZ)](https://azure.microsoft.com/), and [Google Cloud Platform (GCP)](https://cloud.google.com/).
## 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](https://www.cloudflare.com/learning/serverless/what-is-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 deploymentThe application itself is a simple text analysis service that comes with a web-based frontend:
![A screenshot of the sample web app](.github/images/screenshot.png)
## Contents
The relevant parts of this repository are:
| Folder/File | Description |
| ---- | ----------- |
| [.devcontainer/](.devcontainer) | The [vscode devcontainer](https://code.visualstudio.com/docs/remote/containers) for this project |
| [.github/](.github/) | Reamd resources |
| [.vscode/](.vscode/) | [vscode](https://code.visualstudio.com/) settings |
| [aws/](aws/) | The AWS deployment |
| [azure/](azure/) | The Azure deployment |
| [common/](common/) | Common parts of the deployments |
| [common/api/](common/api/) | The OpenAPI config |
| [common/function/](common/function/) | The code for the FaaS function |
| [common/website/](common/website/) | The static website for the frontend |
| [common/mime-types.json](common/mime-types.json) | The MIME type definitions for uploads |
| [gcp/](gcp/) | The GCP deployment |
| [justfile](justfile) | The just configuration |## Setup
You can start up this project rather quickly using the [vscode devcontainers](https://code.visualstudio.com/docs/remote/containers), which are based on Docker.
Using the command runner [just](https://github.com/casey/just/), apply the Terraform configuration using `just apply `, 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)](https://en.wikipedia.org/wiki/Function_as_a_service) offerings). The frontend needs to be served using a [Content Delivery Network (CDN)](https://www.cloudflare.com/learning/cdn/what-is-a-cdn/) to improve stability and page speeds. The FaaS function of the backend should sit behind an [API Gateway](https://www.redhat.com/en/topics/api/what-does-an-api-gateway-do).
### Amazon Web Services
![The AWS architecture](.github/images/aws.png)
### Azure
![The AZ architecture](.github/images/az.png)
#### Caveats
- Functions can be called directly, bypassing the API Gateway
- Terraform currently only supports one origin per API Gateway
- Functions don't support ES6-style JavaScript modules (https://github.com/Azure/azure-functions-nodejs-worker/issues/104). However, this feature is in preview https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node#ecmascript-modules### Google Cloud Platform
![The GCP architecture](.github/images/gcp.png)
#### 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](https://github.com/LucyBot-Inc/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`).