How to Deploy Medusa on AWS with Microtica: A step-by-step guide

·

4 min read

How to Deploy Medusa on AWS with Microtica: A step-by-step guide

Medusa is an open source composable commerce platform built for developers. Its architecture is flexible enabling users to build bespoke commerce solutions.

Medusa is composed of three components:

  1. A headless backend engine that holds all the logic and data of the store and exposes APIs to communicate with the admin and storefront,

  2. An admin dashboard that allows store operators to manage their orders and products, and

  3. A storefront, which is ultimately an ecommerce website where customers can preview products and make orders.

What is Microtica?

Microtica is a developer self-service platform that enables you to self-host open source solutions on AWS (Amazon Web Services) without being a cloud expert.

The platform provides production-ready templates for development frameworks and solutions, so you can get started fast and be free from the friction of dealing with the underlying cloud complexities.

Using the templates, you can deliver on your own AWS account and deploy applications/services on Amazon EKS (Elastic Kubernetes Service).

Why Should You Deploy Medusa Server on AWS?

Here are some of the reasons why it would be a good idea to deploy a Medusa.js Server on AWS with Microtica’s template:

  • Out-of-the-box serverless infrastructure with Fargate

  • Infrastructure and data ownership on your AWS account

  • Auto-scaling based on application load

  • Automated git-push deployments and rollbacks

  • Production-ready solution

  • Resource monitoring and performance insights in-app

Prerequisites

To follow through with this tutorial, here’s a list of things you should have/do.

Deploy a New Medusa Server

After creating a Microtica account, click the Deploy with Microtica button to land on the Templates page, where you can see a list of all production-ready templates.

This template creates the following infrastructure resources that will be provisioned on your AWS account:

  • VPC, subnets and networking

  • Container infrastructure based on Fargate

  • Application load balancer

  • Persistent storage

  • S3 bucket

  • Postgres database

  • Redis (in production mode)

The steps to deploying a new Medusa server are outlined below.

Create a Git Repository

Connect your preferred Git account. Microtica will create a repository on your Git account with a default repo name medusa-server.

Configure Template

Here, you can customize the template for your needs by providing environment variables. Enter an application name and the admin credentials that will be used to create an initial admin user with which you can later sign in to your Medusa Admin.

Select whether you want a production Medusa Server environment or a development one. In production mode, this template will provision managed RDS PostgreSQL and Redis instances. In development mode, the template will use local SQLite and a fake Redis instance.

Environment variables can be updated, added, or configured after deployment as well.

Connect an AWS account

In the last step, you can select the environment in which you want to deploy the template. An existing default environment called development will be preselected here or you can create a new environment.

Connect your AWS account when prompted. This process takes only a few seconds, so afterwards, only choose the region you want to deploy in.

Deploy the Medusa Server Template to AWS

Finally, a deployment summary of what will be provisioned on your AWS account is presented.

Clicking the Deploy button will trigger a deployment of the template and start creating the infrastructure for a Medusa Server.

It will take about 10 mins for the solution to be deployed on the cloud; you can follow the build pipeline in real time by clicking the View Logs button.

Once the build process is complete, a new deployment with the infrastructure resources is triggered. You can follow the logs of the deployment process by clicking the View deployment button, and then selecting the deployment from the list.

Preview the Environment

After the deployment is finished, navigate to ResourcesAppNameOverview, and under Resource Outputs you should see the AccessUrl.

This is the server URL that you can use to access API endpoints. Try getting the list of products using the endpoint /store/products.

The image below shows how your environment should look after deploying both templates.

Cleanup

To remove all the resources created on your AWS account, navigate to your environment → Environment SettingsInfrastructure, and you’ll see the Undeploy section.

This will clean up the resources created in AWS, but you will still have the configuration in Microtica in case you want to deploy it in the cloud again.

Deploy an Existing Medusa Server

If you already have an existing Medusa server repository that you want to migrate to AWS, there are several changes you need to make to your source code. You can follow the documentation to configure and import your Medusa server repo code.

Should you have any issues or questions related to Medusa, then feel free to reach out to the Medusa team via Discord.