Install on AWS
This guide will perform a complete production-ready installation in your AWS environment using AWS CDK.
This is a complex multi step process, and requires high proficiency with AWS, Node.js, and command line tools.
Medplum strives to make this as easy as possible, but despite our best efforts, it is still challenging.
If you have any questions, please contact us or join our Discord.
If you are new to AWS CDK, we strongly recommend reading Getting started with the AWS CDK.
At a high level, the process of installing Medplum on AWS includes:
- Prerequisites
- Setting up IAM permissions
- Setting up an SES account
- Configuring your domain
- Creating a config repo
- Setting up CDK
- Setting up Medplum CDK
- Running the Medplum init tool
- Deploying the CDK stack
- Bootstrapping
- Synth
- Deploy
- Deploying the Medplum app
- Building the Medplum app with your config
- Deploying the Medplum app to AWS
The resulting AWS configuration will look like the following:
Use this video guide as you follow the instructions:
Prerequisites
AWS CLI Setup
It is recommended to setup the AWS Command Line Interface (AWS CLI) by following these instructions.
AWS Credentials Setup
AWS CLI and credentials are required by medplum aws init
automate certain tasks, such as creating public key pairs.
If you have not already done so, follow these instructions to set up your AWS credentials file.
AWS Account Number
The Medplum aws init
command will ask for your AWS Account Number.
If the AWS CLI and credentials are configured, then the tool will automatically identify your AWS Account Number.
If not, you can find your AWS Account Number:
- Sign in to the AWS Management Console with your user name.
- In the top navigation bar, choose Support and then choose Support Center.
- Your AWS account ID (account number) appears below the top navigation bar.
AWS Permissions
You will need permission to access the following AWS services:
Service | Details |
---|---|
Elastic Compute Cloud (EC2) | Create a Virtual Private Cloud (VPC) and related security groups |
Elasticache | Create a hosted Redis cluster for caching and task queue |
Elastic Load Balancing (ELB) | Create a load balancer for server redundancy and high availability |
Identity and Access Management (IAM) | Create service roles for the API server and bot lambdas |
CloudFront | Securely deliver content with low latency and high transfer speeds |
CloudWatch Logs | Create and manage log groups for server logs |
Relational Database Service (RDS) | Create a hosted Postgres Aurora database |
Route 53 | Create DNS entries for the services |
Simple Storage Service (S3) | Host static web content, store and retrieve dynamic user content for file attachments |
Secrets Manager | Store encrypted secret configuration details such as database credentials |
Systems Manager (SSM) | Store configuration details |
Web Application Firewall (WAF) | Protect your web applications or APIs against common web exploits and bots |
Configure your name servers
Medplum strongly recommends configuring your domain to use Amazon's Route 53 as your custom DNS name server. This will make it much easier to set up SSL certificates for the Medplum App and Medplum Binary Storage.
If you choose not to go this route, you will be responsible for setting up your own SSL certificates.
Setup SES
It is strongly recommended to setup an SES email address with production access, meaning that it can send email to any email recipient. Email is used to verify identities, send login instructions, and handle password reset requests.
Follow the Creating and verifying identities in Amazon SES guide to register an email address for system generated emails.
Choose an environment name
Throughout this document, instructions will refer to an "environment name". This environment name is used in multiple places, for example an environment named demo
will result in:
- As part of config file names (i.e.,
medplum.demo.config.json
) - As the base of CloudFormation stack names (i.e.,
MedplumDemo
) - AWS Parameter Store keys (i.e.,
/medplum/demo/...
)
If you plan to deploy multiple Medplum clusters, you may want to consider a naming strategy.
For example:
Env Name | Config file name | CloudFormation stack name | Parameter Store prefix |
---|---|---|---|
prod | medplum.prod.config.json | MedplumProd | /medplum/prod/... |
staging | medplum.staging.config.json | MedplumStaging | /medplum/staging/... |
test | medplum.test.config.json | MedplumTest | /medplum/test/... |
alice | medplum.alice.config.json | MedplumAlice | /medplum/alice/... |
bob | medplum.bob.config.json | MedplumBob | /medplum/bob/... |
Medplum configuration files and environment names are quite flexible, but it is always recommended to be consistent and stay organized.
Setup a config repo
Create your config repo
Medplum recommends creating a separate git repository and npm project to manage your CDK infra-as-code. This repository will only contain JSON configuration files.
mkdir my-medplum-cdk-config
cd my-medplum-cdk-config
npm init -y
Medplum recommends pushing this git repository to your source control provider such as GitHub or GitLab.
Add CDK dependencies
If you have not already done so, add the common AWS CDK dependencies. This includes all of the base CDK capabilities and constructs.
npm i aws-cdk-lib cdk constructs
Add Medplum dependencies
Add the Medplum CDK and CLI dependencies. This includes the Medplum CDK construct.
npm i @medplum/cdk @medplum/cli