Skip to content

amz-x/serverless-starter

Repository files navigation

Serverless Starter

The serverless starter template is built using AWS's cloud computing services, including API Gateway, Lambda, RDS, Cognito, VPC, ACM, Route53, S3 and Cloudfront. The infrastructure as code (IaC) approach ensures that the entire solution can be deployed and managed consistently and reliably, with changes made through version control.

Initially started the template in December 2022, and set a personal deadline to release a MVP before end of March 2023.

The idea was to learn about about the technologies and frameworks used in this template, and create a template I could open and share with the world.

Please feel free to open an issue if you would like to help extend and improve this template!


Table of Contents

  1. Roadmap
  2. Overview
    1. AWS Services
    2. Terraform
    3. NestJS Framework
    4. Angular Framework
    5. CoreUI
    6. PNPM
    7. Nix Package Manager
  3. Setup
    1. Requirements
    2. AWS Account
    3. AWS Route 53 Root Domain
    4. Nix Setup
  4. Terraform Setup and Deployments
    1. Terraform Setup
    2. Terraform Deployments
  5. Disclaimer

Roadmap

  • Switch to devenv from nix shell
  • Add more notes / documentation
  • Create project logo
  • Add acknowledgement section in README.md
  • Setup contributing guidelines
  • Improve code quality
  • Improve Dashboard with light and dark mode
  • Tests in API & Web Application
  • CI/CD Integration

Overview

Feature Description
AWS Cloud Platform
Terraform CDK Infrastructure as Code
Typescript Codebase Language
Nest.js API Framework
Angular 15 Web App JS Framework
Bootstrap 5 Web App CSS Framework
CoreUI Web App Boilerplate Framework
Nix Package Management
DevEnv Nix Development Environment

AWS Services

  • AWS Route53
  • AWS ACM
  • AWS API Gateway
  • AWS RDS PostgreSQL
  • AWS Cognito
  • AWS Cloudfront
  • AWS Lamba
  • AWS S3
  • AWS VPC
  • AWS IAM

Terraform

Terraform is an open source Infrastructure as Code tool, created by HashiCorp.

Terraform supports a number of cloud infrastructure providers such as Amazon Web Services, Cloudflare, Microsoft Azure, IBM Cloud, Serverspace, Google Cloud Platform, DigitalOcean, Oracle Cloud Infrastructure, Yandex.Cloud, VMware vSphere, and OpenStack.

Cloud Development Kit for Terraform (CDKTF) lets you use familiar programming languages to define and provision infrastructure.

CDKTF


NestJS Framework

NestJS Framework built with TypeScript. A progressive NodeJS framework for building efficient and scalable server-side applications.

Why NestJS?

NestJS Features


Angular Framework

Angular is a development platform for building mobile and desktop web applications using TypeScript or JavaScript and other languages.

Angular Features


CoreUI

CoreUI is the fastest way to build a modern dashboard for any platforms, browser, or device. A complete UI Kit that allows you to quickly build eye-catching, high-quality, high-performance responsive applications.

Angular Components Library built on top of Bootstrap 5 and TypeScript.

Why CoreUI?

CoreUI Features


PNPM

PNPM fast, disk space efficient package manager for Node.js.

Why PNPM?

PNPM Features


Nix Package Manager

Nix powerful package manager for Linux and other Unix systems.

Why Nix?

Nix Features

What is NixOS & Nixpkgs?

Nixpkgs is a collection of over 80,000 software packages that can be installed with the Nix package manager. It also implements NixOS, a purely-functional Linux distribution.

What is Devenv?

Fast, Declarative, Reproducible, and Composable Developer Environments using Nix


Setup

Requirements

  • AWS Account
  • Registered root domain on AWS Route53
  • Nix package manager
  • Visual Studio Code (optional, but recommended)

AWS Account

An AWS account is required, sign up if you have don't have one:

https://portal.aws.amazon.com/billing/signup

AWS Route 53 Root Domain

A Route 53 hosted zone / root domain (example.com) is needed, follow the steps below if you don't have one:

  1. Go to the AWS Management Console, look for Route53 service and Click on “Get started now” under the DNS management. AWS Route 53 - Step 2

  2. Click on “Create Hosted Zone” and enter the domain name which you would like to use. AWS Route 53 - Step 2


Nix Setup

Quick Start

# Linux (non-NixOS)
sh <(curl -L https://nixos.org/nix/install) --daemon

# Mac
sh <(curl -L https://nixos.org/nix/install)

# Windows (run in WSL - non-NixOS Linux distributions)
sh <(curl -L https://nixos.org/nix/install) --no-daemon

Highly recommended to follow the official nix package manager installation guide.


Nix Setup - Automatic Shell Activation

Higly recommend to following the official guide to enable automatic shell activation via direnv.


Resources & Manuals


Visual Studio Code (VS Code)

Download & install VS Code:

VS Code extensions:

More extensions for Visual Studio Code can be found on the VS Code Marketplace.


Development Environment

  1. Open a terminal and go to the root of the project directory, and create a copy of the .env-sample and rename it to .env, and fill in the details if needed.

  2. Execute the following step, if direnv is not installed:

    nix develop --impure
  3. Install NodeJS dependencies for all sub-projects by executing the following in the root project directory:

    npm install
  4. Setup the local development environment services including PostgreSQL server:

    Starting all services:

    devenv up

    Stopping all services, by killing the terminal which you executed devenv up.

  5. Start the local development environment API:

    npm run api:start
  6. Start the local development environment WEB APP:

    npm run webapp:start

Terraform Setup and Deployments

Terraform Setup

  1. In the project root directory, create a copy the file ./terraform/lib/config/example.index.ts and rename it to ./terraform/lib/config/index.ts.

      cp -v ./terraform/lib/config/example.index.ts ././terraform/lib/config/index.ts
  2. Replace the values within the file ./terraform/lib/config/index.ts with your preferred configuration.

  3. Execute the following in the terraform directory:

      # Terraform Synth
      npm run synth

Terraform Deployments

  1. Deploy the API stack from the project root directory, execute:

      # Build API
      npm run api:build
      # Builds & Deploy API Stack
      npm run api:deploy
  2. Deploy the WEBAPP stack from the project root directory, execute:

      # Build App
      npm run webapp:build
      # Builds & Deploy App Stack
      npm run webapp:deploy
  3. Backup Terraform stack state from the project root directory, execute:

      # Backup Terraform State to S3
      npm run tf:backup

Disclaimer

Please note that all images used in the README.md are the property of the respective projects/technologies that are being referenced. I do not claim ownership of these images, and they are used solely for illustrative purposes to help describe the features and functionality of the starter template. If you believe that any image has been used inappropriately, please contact me immediately so that I can take appropriate action.