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 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
- 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
.