AWS Elastic Beanstalk
What is Elastic Beanstalk?
Elastic Beanstalk is a Platform as a Service (PaaS) that provisions and manages the AWS infrastructure needed to run your web application — you just upload your code.
- EC2 instance provisioning
- Load balancer configuration
- Auto Scaling group setup
- Application server installation
- OS and platform patching
- Health monitoring and dashboards
- Your application code
- Instance type selection
- Database configuration (RDS)
- VPC and subnet placement
- Environment variables
- Scaling thresholds and triggers
Key point: There is no additional charge for Beanstalk itself — you pay only for the underlying EC2, ELB, and other AWS resources it provisions.
Supported platforms
Elastic Beanstalk provides pre-configured runtime environments — called platforms — for popular application stacks.
- Node.js
- Python
- Ruby
- PHP
- Go
- Java (Corretto)
- .NET (Windows & Linux)
- Docker (single container)
- Multi-container Docker (ECS-backed)
Docker platform lets you bring any runtime — if it runs in a container, Beanstalk can host it.
Build your own platform using Packer if none of the managed options match your stack.
Useful for legacy stacks or specialized server configurations.
AWS manages platform updates (security patches, runtime versions). You choose whether to apply them immediately or on a maintenance window.
Core concepts: application, version, environment
Each environment is independent infrastructure. Deploy v2.0 to staging, test it, then swap URLs between staging and production with a CNAME swap — zero downtime.
Deployment policies
| Policy | How it works | Downtime? | Best for |
|---|---|---|---|
| All at once | Deploy to all instances simultaneously | Yes — brief outage | Dev/test only |
| Rolling | Deploy to one batch at a time; batches serve traffic in turn | No | Production with reduced capacity acceptable |
| Rolling with additional batch | Launches extra instances first; full capacity maintained | No | Production requiring full capacity during deploy |
| Immutable | New instances in a fresh ASG; swap on health check pass | No | Safest for production — quick rollback |
| Blue/Green | Full parallel environment; CNAME swap flips traffic | No | Zero-downtime with instant rollback capability |
Beanstalk vs raw EC2 vs Fargate
| Consideration | Raw EC2 | Elastic Beanstalk | Fargate (ECS) |
|---|---|---|---|
| Service model | IaaS | PaaS | Serverless containers |
| Infrastructure setup | You build everything | Auto-provisioned | No servers at all |
| Deploy artifact | AMI / scripts | App bundle (zip/WAR/Docker) | Container image |
| OS access | Full | Yes (SSH in) | No OS access |
| Operational overhead | High | Medium | Low |
| Underlying compute | EC2 | EC2 (managed) | Fargate micro-VMs |
Beanstalk is a good fit when your team knows a web framework but doesn't want to learn AWS infrastructure setup. It's the on-ramp to EC2 — you can always eject and manage the resources directly later.
Customizing environments: .ebextensions
Place configuration files in a .ebextensions/ folder in your application bundle to customize the environment during deployment.
What you can configure
- Install additional packages (
yum,apt) - Run shell commands before/after deployment
- Set environment variables
- Configure load balancer rules
- Set up log rotation and CloudWatch agent
- Define IAM instance profiles
packages:
yum:
nginx: []
commands:
start_nginx:
command: service nginx start
Files are YAML. Beanstalk applies them in alphabetical order — name files like 01_packages.config, 02_commands.config to control order.
Key takeaways
- Beanstalk = PaaS — upload your code; AWS wires up EC2, ELB, and Auto Scaling automatically
- No extra charge — you pay only for the underlying AWS resources Beanstalk provisions
- Environments are independent; run production and staging in parallel, swap with CNAME
- Immutable deploys are the safest production strategy — instant rollback by re-swapping
- .ebextensions give you full customization without losing the managed experience
Beanstalk is a Heroku-style deployment experience built on top of AWS. You get the simplicity of a PaaS with the full power of the AWS ecosystem underneath.
Use Beanstalk when your team wants to focus on application code, not infrastructure. Graduate to raw EC2 or containers when you need more control.
Review questions
- What service model does Elastic Beanstalk represent?
- Is there an additional charge for using Elastic Beanstalk?
- What is the difference between an application version and an environment?
- Which deployment policy provides the fastest rollback for production?
- A Python developer wants to deploy a Django app on AWS without learning about load balancers or Auto Scaling. Which service is the best fit?
- Your team needs to test a new version alongside the current production version, then switch with zero downtime. What Beanstalk deployment strategy would you use?
- You need to install a custom OS package on every instance Beanstalk provisions. How do you do this?
Next: AWS Lambda — serverless functions. What happens when you remove even the application server and just run code?