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 https //docs microtica com/sqpu assign 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 https //app microtica com/templates/new?template=https //raw\ githubusercontent com/microtica/templates/master/medusa server/ microtica/template yaml 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 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 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