AWS Elastic Beanstalk
Platform as a Service (PaaS) — deploy and manage web applications without infrastructure complexity, covering deployment policies, environment tiers, and .ebextensions.
Overview
AWS Elastic Beanstalk is a Platform as a Service (PaaS) — upload application code and Beanstalk automatically handles provisioning, load balancing, auto scaling, and health monitoring of the underlying infrastructure.
Beanstalk supports multiple platforms (Java, .NET, Node.js, Python, Ruby, Go, PHP, Docker) and deploys applications on familiar AWS resources (EC2, ALB, ASG, RDS, S3) while retaining full control over those resources when needed.
Core Concepts
| Concept | Description |
|---|---|
| Application | Top-level container — a logical collection of environments, versions, and configurations |
| Environment | A running instance of an application version on AWS infrastructure (web server or worker) |
| Application Version | A labelled iteration of deployable code, stored as a ZIP/WAR in S3 |
| Environment Tier | Web Server (handles HTTP via ALB) or Worker (processes jobs from SQS) |
| Platform | The OS, runtime, web server, and Beanstalk components (e.g., Python 3.11 on Amazon Linux 2023) |
| Configuration | Settings controlling instance type, scaling, load balancer, environment variables, etc. |
| .ebextensions | YAML/JSON config files in .ebextensions/ that customise the environment at deploy time |
| Saved Configuration | Reusable named snapshot of environment settings |
Environment Tiers
| Tier | Purpose | Components |
|---|---|---|
| Web Server | Serve HTTP requests from end users | ALB/NLB + ASG + EC2 instances |
| Worker | Process background tasks from a queue | SQS queue + ASG + EC2 instances (daemon) |
Web Server Tier Worker Tier
┌─────────────┐ ┌─────────────┐
│ ALB │ │ SQS Queue │
└──────┬──────┘ └──────┬──────┘
│ │
┌──────▼──────┐ ┌──────▼──────┐
│ EC2 (ASG) │ │ EC2 (ASG) │
│ App Server │ │ Worker Daemon │
└─────────────┘ └─────────────┘SAA/SAP Tip: Use the Worker tier to decouple background processing. A web server environment posts messages to an SQS queue; the worker environment picks them up and processes them. This pattern is a common exam topic for decoupled architectures.
Deployment Policies
| Policy | Downtime | Rollback Speed | Description |
|---|---|---|---|
| All at Once | Yes | Redeploy | Deploys to all instances simultaneously — fastest but causes downtime |
| Rolling | No* | Redeploy | Deploys in batches; reduces capacity during deployment |
| Rolling with Additional Batch | No | Redeploy | Launches extra instances first to maintain full capacity during rollout |
| Immutable | No | Fast (terminate) | Deploys to a fresh ASG; swaps in on success; safest for production |
| Traffic Splitting | No | Fast (reroute) | Canary-style — sends a percentage of traffic to new version, then shifts |
| Blue/Green (manual) | No | Swap URLs | Two separate environments; swap CNAMEs after validation |
Exam Trap: "Immutable" and "Blue/Green" are different deployments. Immutable creates new instances within the same environment. Blue/Green creates an entirely new environment and swaps CNAMEs — it is not a built-in policy but a manual strategy.
.ebextensions
Configuration files placed in the .ebextensions/ directory at the application root customise the environment during deployment.
- File format: YAML or JSON with
.configextension (e.g.,.ebextensions/01-packages.config) - Processed in alphabetical order by filename
- Can install packages, create files, run commands, configure services, and set option settings
# .ebextensions/01-packages.config
packages:
yum:
git: []
option_settings:
aws:elasticbeanstalk:application:environment:
NODE_ENV: production
container_commands:
01_migrate:
command: "npm run migrate"
leader_only: trueKey sections: packages, sources, files, commands, container_commands, option_settings, services.
leader_only: true ensures a command runs on only one instance during deployment — useful for database migrations.
Beanstalk with RDS
| Approach | Description | Recommendation |
|---|---|---|
| RDS inside environment | RDS created and managed by Beanstalk; tied to environment lifecycle | Development/testing only |
| RDS outside environment | RDS created independently; connection string via env variables | Production — decoupled lifecycle |
Exam Trap: If RDS is created inside a Beanstalk environment, deleting the environment also deletes the database. For production, always create RDS independently and pass the endpoint via environment variables.
Common Use Cases
- Rapid prototyping — Deploy a web application in minutes without configuring infrastructure manually.
- Standard web applications — Run Java, .NET, or Node.js apps with auto scaling and health monitoring out of the box.
- Decoupled processing — Web server tier + worker tier pattern for handling async tasks (image processing, email sending).
- Docker deployments — Run single-container or multi-container Docker applications on Beanstalk's Docker platform.
- Development/staging environments — Quickly spin up isolated environments for testing.
SAA/SAP Exam Tips
SAA/SAP Tip: Elastic Beanstalk provides the easiest path to deploy a web application on AWS with full control retained over underlying resources. If the question mentions "developer productivity" or "minimal infrastructure management" for a standard web app, Beanstalk is the likely answer.
Exam Trap: Beanstalk itself is free — charges apply only for the underlying resources (EC2, ALB, RDS, etc.) that it provisions. This is a key difference from higher-abstraction services like App Runner.
SAA/SAP Tip: For zero-downtime deployments, choose Rolling with Additional Batch or Immutable. For the safest production deployment with fast rollback, Immutable is preferred.
Cross-Cloud Equivalents
| Provider | Service / Solution | Notes |
|---|---|---|
| AWS | AWS Elastic Beanstalk | Baseline |
| Azure | Azure App Service | Similar PaaS; more opinionated platform choices |
| GCP | Google App Engine | Standard (sandboxed) and Flexible (Docker) modes |
| On-Premises | Heroku, Dokku, Cloud Foundry | PaaS platforms for self-hosted environments |
Pricing Model
| Dimension | Unit | Notes |
|---|---|---|
| Elastic Beanstalk | Free | No charge for the service itself |
| EC2 instances | Per use | Standard pricing (On-Demand, Reserved, Spot) |
| Load balancers | Per hour + LCU | ALB/NLB pricing applies |
| RDS (if provisioned) | Per use | Standard RDS pricing |
| S3 (app versions) | GB-month | Application version bundles stored in S3 |
Related Services / See Also
- Amazon EC2 — underlying instances managed by Beanstalk
- AWS Auto Scaling — scaling policies applied automatically by Beanstalk
- Elastic Load Balancing — ALB/NLB provisioned by web server environments
- Amazon ECS and EKS — container orchestration for more control
- AWS Lambda — serverless alternative when no infrastructure is desired
Amazon ECS and EKS
Container orchestration services — ECS with Fargate/EC2 launch types and EKS for managed Kubernetes, covering task definitions, services, and decision criteria.
AWS Lambda
Serverless compute service — run code without provisioning servers, covering concurrency, cold starts, layers, destinations, and event-driven patterns.