How to Deploy a Medusa Server on AWS for FREE
Medusa is an open-source, Node.js e-commerce alternative to Shopify. Medusa is composed of three components:
- a headless backend engine that holds all the logic and data of the store and exposes APIs to communicate with the admin and storefront. The Medusa Server
- an admin dashboard that allows store operators to manage their orders and products
- a storefront, which is ultimately an e-commerce website where customers can preview products and make orders
Why 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
- Autoscaling based on application load
- Automated git-push deployments and rollbacks
- Production-ready solution
- Resource monitoring and performance insights in-app
- A Git account. Any provider from GitHub, BitBucket, GitLab, and CodeCommit is supported.
- Create a Microtica account by signing up with your email or your Git account.
- You need to have an AWS account to be able to deploy a react app to your AWS account. Here you can sign up for an AWS account.
Deploy a new Medusa Server
After creating a Microtica account, click the Deploy app 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,
- and Redis (in production mode)
1. 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`.
2. 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/configured after deployment as well.
3. 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 afterward only choose the region you want to deploy in.
4. 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 around 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.
5. Preview the environment
After the deployment is finished, navigate to Resources → [AppName] (Medusa in our case) → Overview, 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.
To remove all the resources created on your AWS account, navigate to your environment → Environment Settings → Infrastructure, 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 our documentation to configure and import your Medusa server repo code.