What is AWS Elastic Beanstalk, what does it manage for you, and what are its deployment options?
Answer
AWS Elastic Beanstalk is a platform as a service that deploys and runs web applications on AWS for you: you upload your code, and it provisions EC2 instances, an Auto Scaling group, a load balancer, health monitoring and logging. It supports Java, .NET, PHP, Node.js, Python, Ruby, Go and Docker, there is no extra charge for Beanstalk itself, and you still have full access to the underlying resources.
What Beanstalk creates
When you create an environment, Beanstalk uses CloudFormation behind the scenes to build:
EC2 instances running a platform (for example "Node.js 20 on Amazon Linux 2023").
An Auto Scaling group with scaling triggers.
An Elastic Load Balancer (usually an ALB) for load-balanced environments, or a single instance for cheap dev setups.
Security groups, CloudWatch alarms, log rotation to S3 and enhanced health reporting.
Key terms:
Application: the logical container.
Application version: a specific uploaded bundle (zip or Docker image reference) stored in S3.
Environment: a running copy of one version, such as shop-prod or shop-staging.
Environment tiers
Web server tier: serves HTTP traffic behind a load balancer.
Worker tier: a daemon on each instance pulls messages from an SQS queue and POSTs them to your app on localhost, useful for background jobs like sending invoices or resizing images. It also supports periodic tasks via cron.yaml.
Deployment policies
Policy
How it works
Downtime
Rollback
All at once
Deploy to every instance together
Yes
Redeploy old version
Rolling
Update instances in batches
No, but reduced capacity
Redeploy
Rolling with additional batch
Launch an extra batch first, keep full capacity
No
Redeploy
Immutable
New instances in a temporary ASG, swap when healthy
No
Fast, terminate new ASG
Traffic splitting
Canary: send a percentage of traffic to new instances
No
Fast
Blue/green is done outside these policies: create a second environment, deploy there, then swap environment URLs (CNAME swap).
Customizing the platform
.ebextensions/*.config files set option settings, install packages and create resources.
.platform/hooks/ and .platform/nginx/ customize Amazon Linux 2 and 2023 platforms, such as running a script before deploy or changing nginx settings.
Saved configurations and environment properties hold config and environment variables.
Trade-offs and gotchas
Do not create production RDS inside the environment. If you terminate the environment, the database goes with it. Create RDS separately and pass the endpoint in as an environment variable.
Platforms get retired as runtimes and OS versions age, so plan platform upgrades.
Beanstalk is great for a college project, an MVP or a small team's monolith. As teams grow they usually move to ECS, EKS or a CDK/Terraform-defined stack for finer control.
Compared with App Runner, Beanstalk gives you real EC2 instances you can SSH into and tune; App Runner hides the servers entirely.
Deploying with Elastic Beanstalk. From code bundle to a running, load-balanced environment.
Package the app: Zip your code or reference a Docker image.
Create application version: Bundle is stored in S3.
Provision environment: CloudFormation builds EC2, ASG, ALB and alarms.
Apply deployment policy: Rolling, immutable or traffic splitting.
Monitor health: Enhanced health and logs show instance status.
Code examples
EB CLI workflow
pip install awsebcli
# Inside your project folder
eb init my-shop --platform node.js --region ap-south-1
eb create my-shop-prod --elb-type application --instance-types t3.small
# Set environment variables without baking them into the code
eb setenv NODE_ENV=production DB_HOST=mydb.xxxx.ap-south-1.rds.amazonaws.com
eb deploy # upload a new version and deploy it
eb logs # pull recent logs from instances
eb health --refresh # live instance health view
The EB CLI wraps the whole lifecycle; eb deploy creates a new application version and rolls it out using the environment's deployment policy.