aws-samples / saas-reference-architecture-ecs

This repo provides an end to end SaaS reference architecture implementation using Amazon Elastic Container Service (ECS)
MIT No Attribution
63 stars 22 forks source link
ecs ecs-fargate

Amazon ECS SaaS - Reference Architecture

Developer Documentation

Introduction

Organizations are moving to the SaaS (Software-as-a-service) delivery model to achieve optimized cost, operational efficiency and overall agility in their software business. SaaS helps to onboard their customers (tenants) into a centrally hosted version of the solution, and manage them via a single pane of glass. These SaaS solutions allow the underneath infrastructure components to be shared across tenants, while demanding mechanisms that can implement the multi-tenancy in the architecture to preserve overall security, performance and other non-functional requirements demanded by the use-case. Often, these strategies and their implementation heavily depend on the underneath technologies and AWS managed services that are being used.

This github solution provides code samples, configurations and best practices that help to implement multi-tenant SaaS reference architecture leveraging Amazon Elastic Container Service (ECS).

The objective here is to dive deeper into design principals and implementation details in building ECS SaaS reference solution covering necessary technical aspects. We will discuss SaaS control plane functionalities with shared services such as tenant onboarding, user management, admin portals, along with the SaaS application plane capabilities such as ECS compute isolation strategies, request routing at scale, service discovery, storage isolation patterns, API throttling and usage plans, and different ways to ensure security and scalability.

ECS SaaS Reference Solution Overview

The following diagram shows the high-level architecture of the solution that outlines the core components of ECS SaaS. It is a tier-based SaaS, and the three tiers represent three different tenant isolation strategies using Amazon ECS. This would help SaaS providers to have a wide range of technical options to model their SaaS solution based on their tiering requirements.

  1. Basic Tier: Shared ECS Services across all the tenants (Pool model)
  2. Advanced Tier : Shared ECS Cluster, dedicated ECS services per tenant (Silo model)
  3. Premium Tier: Dedicated ECS Cluster per tenant (Silo model)

High-level Architecture Fig 1: ECS SaaS - High-level infrastructure

This reference architecture adopts the latest AWS SaaS Builder Toolkit (SBT) that AWS SaaS Factory has developed. SBT helps to extend the SaaS control plane services such as tenant onboarding, off-boarding, tenant and user management, billing, etc seamlessly into the solution. It also provides an event-based integration to the ECS application plane that enables bi-directional communication for SaaS operations. Read more about AWS SBT here.

Pre-requisites

This solution can be deployed via an AWS Cloud9 environment on your AWS account, or directly from your laptop.

If you are using Cloud9, make sure to use Amazon Linux 2023 AMI for the EC2 with at least t3.large instance size. Also, increase the volume size of the underlying EC2 instance to 50 GB (instead of default 10 GB) using this script ./scripts/resize-cloud9.sh - This is to make sure that you have enough compute and space to build the solution.

Deployment Steps

To deploy this ECS SaaS reference solution, you can run the below commands. Replace the admin_email with a real email address that will be used to create an admin user in the solution, and to share the admin credentials that allow to perform administrative tasks such as onboarding new tenants.

git clone this_repo_url
cd saas-reference-architecture-ecs/scripts
./build-application.sh 
./install.sh admin_email 

Note that, build-application.sh builds docker images of sample SaaS application with order, product & user microservices and pushes to Amazon ECR.

And, install.sh deploys the following:

Steps to Clean-up

Run the following script to clean up reference solution resources from your AWS account. Please make sure that jq JSON processor installed in your environment before invoking below script.

cd scripts
./cleanup.sh

License

This library is licensed under the MIT-0 License. See the LICENSE file.

Security

See CONTRIBUTING for more information.