The most common AWS deployment of Mage is with AWS ECS. Our Terraform scripts manage the process of creating an ECS cluster, a load balancer, and a database. Here’s a link to the default output of
terraform plan on AWS ECS.
An architecture diagram of a Mage AWS ECS deployment.
We use the following AWS services in our deployment:
Elastic Container Service (ECS)
Amazon ECS is a service provided by AWS for managing and deploying containerized applications. The ECS service in Terraform is used to define and configure the ECS clusters and services.
ECS allows you to run containers at scale, and the Terraform configuration for ECS service includes specifying the task definition, desired task count, launch type, and other settings related to container orchestration.
The Mage application runs as multiple containers in an Amazon ECS service.
Application Load Balancer (ALB)
An Application Load Balancer is a service provided by AWS that distributes incoming application traffic across multiple targets, such as EC2 instances, ECS containers, or Lambda functions.
In Terraform, the ALB resource is used to define and configure the load balancer, including listeners, target groups, and rules for routing incoming requests to the appropriate backend targets.
Our ALB is configured to route traffic to the ECS cluster and provides a public URL for communication with clients. Read more here.
Elastic File System (EFS)
Amazon EFS provides a fully managed, scalable, and shared file storage service that can be used with AWS services and on-premises resources.
We use EFS to store a persistent volume where the
mage_data for your project is stored. You can learn more about what is stored in
mage_data here. Without EFS, your project data would be lost when your ECS service is terminated. EFS allows us to persist data between containers within ECS.
Relational Database Service (RDS)
The RDS Instance resource is used to define and configure a specific database instance within the Amazon RDS service.
We use a Postgres RDS to hold the the backend database for your Mage instance. This database contains the metadata that powers Mage. Read more here.
Virtual Private Cloud (VPC)
Amazon VPC allows you to create a virtual network within AWS, enabling you to isolate and control resources in a private, logically isolated section of the AWS cloud.
The VPC resource in Terraform is used to define and configure the virtual network, including its subnets, route tables, security groups, and other networking-related settings.
The Mage application, ALB, ECS, EFS, and RDS are all deployed within a VPC in our Terraform scripts.
You can refer to the instructions found here to learn more about deploying to ECS.