Templates

Medusa Server

11min

Medusa is an open-source composable commerce engine built with Node.js. Medusa enables developers to build scalable and sophisticated commerce setups with low effort and great developer experience.

Infrastructure ownership

The Medusa infrastructure will be provisioned on your own AWS account.

You retain full control over your infrastructure and data while getting all the benefits of infrastructure automation.

One-click Deploy

Click Deploy with Microtica below and follow the template steps to deploy your Medusa Server application on your AWS account.



Medusa Admin

By deploying the template, Medusa Admin will be automatically included and available on<YOUR_APP_URL>/app

To make the Medusa Admin console function correctly, you must assign a Custom Domain from the Microtica console and expose it over HTTPS.

What will be provisioned on AWS

Since Microtica deploys on your cloud account, you would expect nothing less than complete transparency of what resources are going to be provisioned.

Using the Medusa Server template, you will create two components in the environment:

  • VPC — VPC, subnets and networking
  • Medusa - Container infrastructure based on Fargate, application load balancer, persistent storage, S3 bucket, Postgres database, and Redis

Deploy your existing Medusa Server

By default, the template creates a new Medusa Server repo on your Git account with all required setups and no changes required from your side.

But if you already have a Medusa server repo that you want to deploy then you need to perform a couple of changes in your source code.

1. Install the S3 plugin

The first thing you need to do, if you want to use S3 as media storage (recommended), is to install the Medusa S3 plugin.

npm
Yarn


The template automatically creates an S3 bucket so you just need to install the module and set the proper configuration (step 2).

2. Update Medusa config

Second, update your Medusa config (medusa-config.js) by adding the S3 plugin configuration in the plugins section.

medusa-config.js


Built-in environment variables

Below is a list of built-in environment variables provided in the Medusa Server runtime. You can access them with process.env.<VARIABLE NAME>

Name

Description

Required

S3_URL

The URL to your bucket. It’s in the form https://<BUCKET_NAME>.s3.<REGION>.amazonaws.com

Yes

S3_BUCKET

The name of the bucket created automatically by the template.

Yes

S3_REGION

The region code of your bucket. For example us-east-1.

Yes

DATABASE_URL

The connection string to the Postgres database instance

No

REDIS_URL

The connection string to the Redis instance

No

COOKIE_SECRET

Auto-generated strong cookie secret (128 characters long).

Yes

JWT_SECRET

Auto-generated strong JWT secret (128 characters long).

Yes

Custom environment variables

Use custom variables to specify the ADMIN_CORS, STORE_CORS, Stripe configuration, etc. The custom variables can be added after the template deployment is completed.

To provide custom environment variables in the Medusa Server runtime, go to your Environment, select the Medusa resource from the list and go to the Resource Settings tab.

Add the custom environment variables in the EnvironmentVariables resource property in the following format: KEY=value,KEY=value.

Click on Save and Deploy button.

Estimated AWS cost

The estimated cost of the AWS cloud depends on the configuration of the Medusa infrastructure. Below is the cost estimation breakdown based on different configurations assuming the resources are running all the time:

  • Postgres and Redis with one app container (0.25 vCPU and 0.5GB memory) the cost would be approximately $70/month
  • each additional container with the default config is $14/month

Optimize AWS cost

To save costs while using Medusa in a non-production environment, consider running it from Monday to Friday, 8 hours per day. This schedule can help you achieve at least a 65% reduction in your cloud expenses.

In the Resources or Cost Dashboard, create a Saving Schedule to implement these cost-saving measures.

Document image