DEV Community

Cover image for Load-Balanced MEAN-Stack by AWS CloudFormation & Docker 🐳
Thomas Gotwig
Thomas Gotwig

Posted on

5 4

Load-Balanced MEAN-Stack by AWS CloudFormation & Docker 🐳

In this short article I will show how to deploy a Mean-Stack app by AWS-CLI and CloudFormation using a v1 load-balancer 😃

All the code regarding our deployment you can also find here:
https://github.com/TGotwig/devops

We take usage of an very nice and simple MEAN-Stack project which comes from Brad Traversy 🤗

Download the sample repo and cd into it:

git clone git@github.com:TGotwig/devops.git
cd aws-cloudformation/solutions/advanced/mean-stack
Enter fullscreen mode Exit fullscreen mode

⚙️ Setup awscli

Install the awscli from somewhere and login:

aws configure --profile <YOUR_AWS_ACCOUNT_NAME>
Enter fullscreen mode Exit fullscreen mode

You will be asked for two IDs, you can get them through:

Click on your name at the top right corner and then on  raw `My Security Credentials` endraw

Open the tab  raw `Access keys (access key ID and secret access key)` endraw

Let it create two keys for you for later use

⚙️ Setup ssh

Create a file called parameters.json:

[
  {
    "ParameterKey": "KeyName",
    "ParameterValue": "<KeyName>"
  }
]
Enter fullscreen mode Exit fullscreen mode

Replace <KeyName> by your SSH key under EC2 / Key Pairs:

Screenshot_2020-10-10 Key pairs EC2 Management Console(1)

⚙️ Setup Makefile

Create a file called .env for the Makefile:

stack-name=simple-mean-stack
profile=<YOUR_AWS_ACCOUNT_NAME>
region=<YOUR_AWS_REGION>
Enter fullscreen mode Exit fullscreen mode

🚀 Run it!

Start it by running make up, an EC2 machine should boot up:

Created EC2 machine with public IPv4 address

After some time we can reach the app, run make getUrl to get the url:

App with ID from machine x

After refreshing the page few times you should see another IP:

App with ID from machine y

You can remove the entire stack by running make rm! 🔥

Awesome! Now we have finished our load-balanced Mean-Stack app 😎🎉

Heroku

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

DEV is better (more customized, reading settings like dark mode etc) when you're signed in!

Okay