Skip to content

atulkamble/elastic-beanstalk-nodejs

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
    or
    pip 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

Here’s how you can list and delete Elastic Beanstalk applications and environments from the AWS CLI:


🔍 1. List Elastic Beanstalk Applications

aws elasticbeanstalk describe-applications

This will return all applications with details (name, description, date created, etc.).

To list only application names:

aws elasticbeanstalk describe-applications \
  --query "Applications[].ApplicationName" \
  --output table

🔍 2. List Elastic Beanstalk Environments

aws elasticbeanstalk describe-environments

To filter environments for a specific application:

aws elasticbeanstalk describe-environments \
  --application-name MyApp

To show only environment names:

aws elasticbeanstalk describe-environments \
  --query "Environments[].EnvironmentName" \
  --output table

❌ 3. Delete Elastic Beanstalk Environment

Before deleting the application, you must terminate its environments:

aws elasticbeanstalk terminate-environment \
  --environment-name my-env

❌ 4. Delete Elastic Beanstalk Application

Once environments are terminated:

aws elasticbeanstalk delete-application \
  --application-name MyApp

If you also want to delete the application versions and S3 sources:

aws elasticbeanstalk delete-application \
  --application-name MyApp \
  --terminate-env-by-force

Recommended sequence:

  1. List applications & environments.
  2. Terminate environments.
  3. Delete the application (with versions if needed).

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published