MicroticaMicrotica

Medusa Server

Deploy a production-ready Medusa commerce backend on your own AWS account, with Postgres, Redis, S3, and Medusa Admin provisioned for you in minutes.

Medusa is an open-source composable commerce engine built with Node.js. It lets developers build scalable, sophisticated commerce setups with a great developer experience. This template deploys a full Medusa Server on AWS, including its database, cache, and storage.

Infrastructure ownership

The Medusa infrastructure runs on your own AWS account.

You keep full control over your infrastructure and data, with 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.

Deploy with Microtica

Medusa Admin

When you deploy the template, Medusa Admin is included automatically and available at <YOUR_APP_URL>/app.

For Medusa Admin to work correctly, assign a custom domain from the Microtica console and expose it over HTTPS.

What will be provisioned on AWS

Microtica deploys on your cloud account, so you get full transparency over the resources it provisions.

The Medusa Server template creates 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 setup and no changes from your side.

If you already have a Medusa Server repo you want to deploy, make a couple of changes to your source code first.

Update Medusa config

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

medusa-config.ts
import { loadEnv, defineConfig } from '@medusajs/framework/utils'

loadEnv(process.env.NODE_ENV || 'development', process.cwd())


module.exports = defineConfig({
  projectConfig: {
    databaseUrl: process.env.DATABASE_URL,
    databaseDriverOptions: {
      connection: { ssl: { rejectUnauthorized: false } }
    },
    redisUrl: process.env.REDIS_URL,
    http: {
      storeCors: process.env.STORE_CORS!,
      adminCors: process.env.ADMIN_CORS!,
      authCors: process.env.AUTH_CORS!,
      jwtSecret: process.env.JWT_SECRET || "supersecret",
      cookieSecret: process.env.COOKIE_SECRET || "supersecret",
    },
    workerMode: "shared"
  },
  modules: [
    {
      resolve: "@medusajs/medusa/file",
      options: {
        providers: [
          {
            resolve: "@medusajs/medusa/file-s3",
            id: "s3",
            options: {
              region: process.env.S3_REGION,
              bucket: process.env.S3_BUCKET,
              file_url: process.env.S3_URL,
              endpoint: process.env.S3_ENDPOINT,
              access_key_id: process.env.S3_ACCESS_KEY_ID,
              secret_access_key: process.env.S3_SECRET_ACCESS_KEY
            },
          },
        ],
      },
    },
  ]
})

// ...

Built-in environment variables

These built-in environment variables are provided in the Medusa Server runtime. Access them with process.env.<VARIABLE NAME>.

NameDescriptionRequired
S3_URLThe URL to your bucket. It’s in the form https://<BUCKET_NAME>.s3.<REGION>.amazonaws.comYes
S3_ENDPOINTThe URL to your bucket. It’s in the form https://s3.<REGION>.amazonaws.comYes
S3_BUCKETThe name of the bucket created automatically by the template.Yes
S3_REGIONThe region code of your bucket. For example us-east-1.Yes
S3_ACCESS_KEY_IDAccess Key for the user with access to S3 storage bucket.Yes
S3_SECRET_ACCESS_KEYSecret Access Key for the user with access to S3 storage bucket.Yes
MEDUSA_BACKEND_URLAccess URL of the Medusa backend service.Yes
DATABASE_URLThe connection string to the Postgres database instanceNo
REDIS_URLThe connection string to the Redis instanceNo
COOKIE_SECRETAuto-generated strong cookie secret (128 characters long).Yes
JWT_SECRETAuto-generated strong JWT secret (128 characters long).Yes

Custom environment variables

Use custom variables to set ADMIN_CORS, STORE_CORS, Stripe configuration, and more. Add them after the template deployment is complete.

To provide custom environment variables in the Medusa Server runtime, open 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 format KEY=value,KEY=value.

Click Save and Deploy.

Estimated AWS cost

The AWS cost depends on the configuration of the Medusa infrastructure. Here is the cost breakdown, assuming the app runs all the time:

  • Postgres and Redis with one app container (0.5 vCPU and 1GB memory) costs 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, run it from Monday to Friday, 8 hours per day. This schedule can cut your cloud expenses by at least 65%.

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

Saving Schedule configuration in the Microtica Cost Dashboard

Next steps

On this page