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-1
Choose:
- Platform:
Node.js
- Region:
us-east-1
(or your preferred region)
eb create eb-node-env
eb open
To set environment variables or configuration:
option_settings:
aws:elasticbeanstalk:application:environment:
NODE_ENV: production
eb deploy
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:
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
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
Before deleting the application, you must terminate its environments:
aws elasticbeanstalk terminate-environment \
--environment-name my-env
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:
- List applications & environments.
- Terminate environments.
- Delete the application (with versions if needed).