Skip to content

atulkamble/elastic-beanstalk-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Elastic Beanstalk project example to help you deploy a sample web application (Node.js, Python, Java, PHP, etc.) in a real-world scenario using Elastic Beanstalk. Below is a Node.js-based project walkthrough, but I can customize it for any language or stack you prefer.


🔧 Project Title: Deploy a Node.js Web App on AWS Elastic Beanstalk


📁 Project Structure

elastic-beanstalk-nodejs/
├── app.js
├── package.json
├── .elasticbeanstalk/
│   └── config.yml
├── .ebextensions/
│   └── 01_environment.config
└── README.md

1️⃣ Prerequisites

  • AWS Account
  • AWS CLI configured (aws configure)
    brew install python3
    python3 --version
    pip3 install --upgrade pip
    pip3 --version
    pip3 install awsebcli
    npm install express
    // https://nodejs.org/en
    node -v
    git clone https://github.com/atulkamble/elastic-beanstalk-nodejs.git
    cd elastic-beanstalk-nodejs
    node app.js
    // http://localhost:3000
    
  • Elastic Beanstalk CLI (pip install awsebcli)
  • Node.js installed

2️⃣ Code: app.js

const express = require('express');
const app = express();
const port = process.env.PORT || 3000;

app.get('/', (req, res) => {
  res.send('Hello from Elastic Beanstalk 🚀!');
});

app.listen(port, () => {
  console.log(`App running on port ${port}`);
});

3️⃣ Dependencies: package.json

{
  "name": "eb-node-app",
  "version": "1.0.0",
  "description": "Simple Node.js app on AWS Elastic Beanstalk",
  "main": "app.js",
  "scripts": {
    "start": "node app.js"
  },
  "dependencies": {
    "express": "^4.17.1"
  }
}

4️⃣ Initialize Beanstalk App

eb init -p node.js -r us-east-1

Choose:

  • Platform: Node.js
  • Region: us-east-1 (or your preferred region)

5️⃣ Create Environment and Deploy

eb create eb-node-env
eb open

6️⃣ Optional: .ebextensions/01_environment.config

To set environment variables or configuration:

option_settings:
  aws:elasticbeanstalk:application:environment:
    NODE_ENV: production

7️⃣ Update & Redeploy

eb deploy

✅ Output

Once deployed, eb open will open the public URL of your app, and you should see:

Hello from Elastic Beanstalk 🚀!

deletion

delete eb env.
delete eb 
delete lb (automatically)
delete s3 backup

📌 Notes

  • You can replace the app with a React, Python Flask, Spring Boot, or PHP project.
  • For Docker-based apps, Elastic Beanstalk supports multi-container and single-container Docker environments using a Dockerrun.aws.json.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published