Templates

Medusa Server

9min

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.

Update Medusa config

Update your Medusa config medusa-config.ts accorting to the following example:

medusa-config.ts


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_ENDPOINT

The URL to your bucket. It’s in the form https://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

S3_ACCESS_KEY_ID

Access Key for the user with access to S3 storage bucket.

Yes

S3_SECRET_ACCESS_KEY

Secret Access Key for the user with access to S3 storage bucket.

Yes

MEDUSA_BACKEND_URL

Access URL of the Medusa backend service.

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 assuming the app is running all the time:

  • Postgres and Redis with one app container (0.5 vCPU and 1GB memory) the cost would be approximately $85/month
  • each additional container with the default config is $20/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