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.
elastic-beanstalk-nodejs/
├── app.js
├── package.json
├── .elasticbeanstalk/
│ └── config.yml
├── .ebextensions/
│ └── 01_environment.config
└── README.md
- 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
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}`);
});{
"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"
}
}eb init -p node.js -r us-east-1Choose:
- Platform:
Node.js - Region:
us-east-1(or your preferred region)
eb create eb-node-env
eb openTo set environment variables or configuration:
option_settings:
aws:elasticbeanstalk:application:environment:
NODE_ENV: productioneb deployOnce 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:
aws elasticbeanstalk describe-applicationsThis will return all applications with details (name, description, date created, etc.).
To list only application names:
aws elasticbeanstalk describe-applications \
--query "Applications[].ApplicationName" \
--output tableaws elasticbeanstalk describe-environmentsTo filter environments for a specific application:
aws elasticbeanstalk describe-environments \
--application-name MyAppTo show only environment names:
aws elasticbeanstalk describe-environments \
--query "Environments[].EnvironmentName" \
--output tableBefore deleting the application, you must terminate its environments:
aws elasticbeanstalk terminate-environment \
--environment-name my-envOnce environments are terminated:
aws elasticbeanstalk delete-application \
--application-name MyAppIf you also want to delete the application versions and S3 sources:
aws elasticbeanstalk delete-application \
--application-name MyApp \
--terminate-env-by-force✅ Recommended sequence:
- List applications & environments.
- Terminate environments.
- Delete the application (with versions if needed).