Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 16, 2023 01:32 pm GMT

Deploy a Medusa Server on AWS with Microtica

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 Microticas 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, heres a list of things you should have/do.

Deploy a New Medusa Server

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

https://res.cloudinary.com/practicaldev/image/fetch/s--j8ltzfzT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2160/0%2AyPM4LolCmcwyo2dz

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 namemedusa-server.

https://res.cloudinary.com/practicaldev/image/fetch/s--7Vz9dgjI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/0%2AAYA_5Qxh0i5w5API

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.

https://res.cloudinary.com/practicaldev/image/fetch/s--hzA-Asi4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/0%2A20qBNOOAx6dJa7dP

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 calleddevelopmentwill 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.

https://res.cloudinary.com/practicaldev/image/fetch/s--wIJw3JpW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/0%2AwD5h7C66rTEtoY6R

Deploy the Medusa Server Template to AWS

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

https://res.cloudinary.com/practicaldev/image/fetch/s--xprIPGyZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/0%2ASu2PvCcwaFvO3quD

Clicking theDeploy 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 theView Logsbutton.

https://res.cloudinary.com/practicaldev/image/fetch/s--fuXB293j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2656/0%2AG40LVuTP_RMldAH0

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 theView deploymentbutton, and then selecting the deployment from the list.

https://res.cloudinary.com/practicaldev/image/fetch/s--Wq6QxO0g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2654/0%2AVCiLvi7cYQWer1sz

Preview the Environment

After the deployment is finished, navigate toResourcesAppNameOverview, and underResource Outputsyou should see theAccessUrl.

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

https://res.cloudinary.com/practicaldev/image/fetch/s--eg5JOtmB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/3200/0%2AT7LKU9ZJHFb4SU8f

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

https://res.cloudinary.com/practicaldev/image/fetch/s--WeEFNNF8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/3200/0%2Abz9gEweLAoAaq3r1

Cleanup

To remove all the resources created on your AWS account, navigate to your environment Environment SettingsInfrastructure, and youll see theUndeploysection.

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 followthe documentationto 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 viaDiscord.


Original Link: https://dev.to/medusajs/deploy-a-medusa-server-on-aws-with-microtica-4840

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To