Home
Tutorial
AWS Express Server

AWS Express Server

AWS Express Server

GET THE #1 EMAIL FOR EXECUTIVES

Subscribe to get the weekly email newsletter loved by 1000+ executives. It's FREE!

Article Description

Guide to deploying express server to AWS Elastic Beanstalk.

Elastic Beanstalk is an AWS EC2 deploying your code similar which supports many languages including Node, Python, Java, Go, Docker etc.

This is the what services like Railway use for their deployments under the hood with Railway just making it easier to deploy with premade tempaltes.Using Beanstalk is also a cheaper alternative

This guide assumes you already have a Express server.You can also use this as guideline for generally deploying any type of app to AWS.

Good reference when creating REST API's here.

1. Set up a role in AWS IAM that has the roles in the screenshot

Beanstalk Role

AdministratorAccess

AWSElasticBeanstalkMulticontainerDocker

AWSElasticBeanstalkWebTier

AWSElasticBeanstalkWorkerTier

2. Navigate to AWS ElasticBeanstalk dashboard and create a new application

-On the first page set a name and such. Platform should be Node (which ever version). Make sure to use the Sample Application (dont upload your own code yet), this way you can be sure the deployment config is correct.

-On the second page use the Beanstalk role created earlier

Beanstalk App Roles

-You should now be able to click 'Skip to Review' at the bottom of the page

-On the Review page double check the Platform Software section is using Nginx, then start the deployment

Config Deployment

-Copy the folder structure from this screenshot, starting from root

Config Folder structure

.ebextensions folder is used to store your Beanstalk deployment config, this runs before your deployment.

playwright.config is the config itself (you can name it whatever you want).I've used it to install additional packages that dont come preinstalled on the linux server.

below is the format for commands. AWS EC2 instances use yum for installing packages

commands:
  01_install_npm:
   command: sudo yum install 'your dependencies'

Config Nginx

The Nginx config folder structure looks like this

.platform\nginx\conf.d\nginx.config

Github Action for CD

This Github work flow automates deployment to AWS whenever main branch gets updated.

.github\workflows\aws.yml

name: Deploy master
on:
  push:
    branches:
    - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:

    - name: Checkout source code
      uses: actions/checkout@v2

    - name: Generate deployment package
      run: zip -r deploy.zip . -x '*.git*'

    - name: Deploy to EB
      uses: einaregilsson/beanstalk-deploy@v21
      with:
        aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        application_name: {your app name}
        environment_name: {your environment name}
        version_label: ${{ github.sha }}
        version_description: ${{github.event.head_commit.message}}
        region: us-east-1
        deployment_package: deploy.zip
        use_existing_version_if_available: true
        wait_for_environment_recovery: 60
Thanks for reading! If you found this helpful, please share this article with 1 friend!

More Articles

What Every CEO Can Learn from GitHub's 100-Day Leadership Challenge

ARTICLE

What Every CEO Can Learn from GitHub's 100-Day Leadership Challenge

How Nat Friedman's Bold 100-Day Strategy Transformed GitHub and Redefined Leadership....

Struggling to Empower Your Team? Read This Book

BOOK REVIEW

Struggling to Empower Your Team? Read This Book

Learn how the best companies build products...

Jeff Bezos is famous for reading slowly - here's why you need to do it too

ARTICLE

Jeff Bezos is famous for reading slowly - here's why you need to do it too

Honestly this is not an easy thing to do. I tried and it felt like the mental equivalent of deadlifting

The Trillion Dollar Coach: Steve Job's Coach

BOOK REVIEW

The Trillion Dollar Coach: Steve Job's Coach

This is a simple book that is a must read for any leader...

25 Strategic Moves That Established Companies Need to Steal from Startups

ARTICLE

25 Strategic Moves That Established Companies Need to Steal from Startups

Sick of slow progress in your organisation? This will help you focus on what matters...

AI paying Humans?

ARTICLE

AI paying Humans?

A new company Payman is betting that the future of work involves AIs paying us to do their boring tasks ...

Do you lead people? Your mood is like electricity - it spreads

ARTICLE

Do you lead people? Your mood is like electricity - it spreads

Discover how a leader's emotional state can spread through an organisation like wildfire, influencing performance at every level...

AI-Powered Networking: Building 50+ Connections in a New City

ARTICLE

AI-Powered Networking: Building 50+ Connections in a New City

Discover how I leveraged AI to transform networking in London, creating a scalable system for building meaningful professional relationships.

51 Books Every Executive Should Read in 2024

BOOKS

51 Books Every Executive Should Read in 2024

Hand picked, each of these has shaped us in some way...

The Time a PhD Mathematician Won the Olympics

ARTICLE

The Time a PhD Mathematician Won the Olympics

The story of Anna Kiesenhofer's incredible victory in Tokyo

Running a large organisation? You need to think this way

ARTICLE

Running a large organisation? You need to think this way

Day one thinking and why you need to make sure that your company thinks like this...

The Economics of Airbnb Icons

ARTICLE

The Economics of Airbnb Icons

Why exactly did they build the UP house?

Olympic Glory in the Digital Age: How Paris 2024 Reshaped Athletes' Social Media Landscapes

ARTICLE

Olympic Glory in the Digital Age: How Paris 2024 Reshaped Athletes' Social Media Landscapes

We look at Instagram follower counts and see if there is a correlation between winning a medal or not...

How Youtube can help you to find your North Star Metric

ARTICLE

How Youtube can help you to find your North Star Metric

Learn why the biggest companies choose one thing to focus on...

No Rules Rules: Netflix and the Culture of Reinvention

BOOK REVIEW

No Rules Rules: Netflix and the Culture of Reinvention

An inside look into the culture of Netflix...

The 5 Word Meeting Technique

ARTICLE

The 5 Word Meeting Technique

Google, Apple and Amazon were told to run their companies this way...

Using a can of beans to figure out consulting pricing

ARTICLE

Using a can of beans to figure out consulting pricing

Get better at pricing your consulting jobs...

The Hidden Psychology of Decision-Making: What Executives Can Learn from Hostage Negotiators

ARTICLE

The Hidden Psychology of Decision-Making: What Executives Can Learn from Hostage Negotiators

Explore how understanding emotional under currents can enhance decision-making in business...

Company

Site Information

Fun Stuff

© 2024 Cub Digital. All Rights Reserved.