How to deploy a Typescript Parse Server on Elasticbeanstalk
May, 23 2022
Sign up for the Thingio beta
Thingio is a new IoT automation platform. Easily configure your projects to send text messages, emails, and more. No need to know cloud programming.
Now that we have our Typescript Parse Server compiling and connecting to our MonoDB database, let's get it deployed to Elasticbeanstalk.
aws configure to sign in to your account with the CLI.
Log into AWS console and create a new elastic beanstalk instance.
web server environment.
Give your new application a name:
It is helpful here to choose a specific domain rather than letting it auto generate so that we can update our Parse config. Take note of the domain that you give your instance.
Choose a Node16 environment with the default settings:
Allow the instance to be created with a sample application and click
While your environment is deploying, navigate to
./.ebextensions/app.config of your Parse Server project and update the
SERVER_URL property with the domain you specified.
./.ebextensions/app.config file contains all of the environment variables that our Elasticbeanstalk instance will be deployed with.
Here you can add the
MASTER_KEY that you want to use for production.
Note that this file should not be checked into git to keep these keys secure.
We can also update the
DATABASE_URI environment variable. You can then remove it from
./src/index.js so that we keep our connection string secure.
Configuring the Elasticbeanstalk Environment
After the sample code is deployed, we'll need to change the instance type to
❗️ This is critical, otherwise the
npm install command will fail on the server.
t2.micro is too small of an instance for Parse Server.
In the side panel of your Elasticbeanstalk console, choose the configuration option.
Scroll down until you find the capacity section and choose Edit.
Find the 'instance types' section and remove
t2.micro while keeping
t2.small or larger.
Initialize our Parse Server as an Elasticbeanstalk instance
In the project's terminal run:
Answer the prompts by selecting the specified region and project name of our new instance when prompted.
Make sure to choose
n when asked if you wish to continue with CodeCommit (assuming you are using Github).
eb init will update our
.gitignore file automatically for us.
In your root directory, create a new folder called
Add a file named
./scripts/dist.sh and fill it with the following shell command:
Next, move on over to your
package.json file and add two new scripts:
Test them out by first running
npm run build and then running
npm run dist.
You can confirm that everything is working by confirming there's a new .zip file in your
Now we'll need to tell the Elasticbeanstalk CLI which zip to upload. Head on over to the
./elasticbeanstalk/config.yml file that was generated with the
eb init command.
Add a new stage called
deploy at the very bottom:
Let's try to deploy and cross our fingers.
But first make sure to commit your changes, otherwise the elasticbeanstalk CLI will not pick them up.
Once the deployment completes, you can test that your Parse Server is running as expected by running the following command:
You should get a response from your
./cloud/functions.ts file with a body of:
Now you have your Typescript Parse Server running on your Elasticbeanstalk environment!