The Complete AWS Elastic Beanstalk Tutorial(2025): Architecture, Deployments, Environments, Scaling & Real-World DevOps Use Cases

Imagine deploying a full-stack application without writing a single line of infrastructure code — that’s AWS Elastic Beanstalk.

I’ve spent years helping DevOps teams transition from manual EC2 deployments to managed platforms, and Elastic Beanstalk consistently surprises engineers with how much heavy lifting it handles behind the scenes. But here’s what most tutorials won’t tell you: understanding what Elastic Beanstalk does under the hood is what separates someone who just deploys apps from someone who architects scalable, production-grade systems.

In this guide, we’re going deep. You’ll learn the architecture, deployment strategies, environment management, auto-scaling mechanics, and real-world DevOps patterns that I’ve used in production environments serving millions of requests.


What is AWS Elastic Beanstalk?

AWS Elastic Beanstalk is a Platform-as-a-Service (PaaS) offering that automates the deployment, scaling, monitoring, and infrastructure management of your applications. Think of it as AWS saying, “You focus on your code — we’ll handle the servers, load balancers, and scaling logic.”

When AWS launched Elastic Beanstalk in 2011, the goal was simple: make it ridiculously easy for developers to deploy applications without becoming infrastructure experts. And it worked.

Here’s what Elastic Beanstalk actually does behind the scenes:

  • Provisions EC2 instances for your application
  • Sets up Elastic Load Balancing (ALB, CLB, or NLB)
  • Configures Auto Scaling Groups for traffic management
  • Integrates CloudWatch for monitoring and health checks
  • Manages application versions in S3
  • Handles OS patches and platform updates
  • Creates underlying infrastructure using CloudFormation

But Elastic Beanstalk isn’t a magic black box. It’s more like a smart orchestrator that configures AWS services you already know — EC2, ELB, ASG, RDS — following best practices so you don’t have to.

When to use Elastic Beanstalk:

  • You’re building a standard web application (Node.js API, Python Flask, Java Spring Boot)
  • You want quick deployments without managing infrastructure
  • Your team is small or doesn’t have dedicated DevOps engineers
  • You need auto-scaling and load balancing without manual setup
  • You’re prototyping or building MVPs

When NOT to use Elastic Beanstalk:

  • You need highly customized infrastructure (use Terraform or CloudFormation instead)
  • You’re running microservices at scale (consider ECS or EKS)
  • You need advanced networking configurations
  • You want serverless architecture (use Lambda)
  • You require multi-region active-active deployments

Real-world example: I once helped a startup deploy a Node.js API serving customer data to a mobile app. Instead of spending two weeks setting up EC2, ALB, ASG, CloudWatch, and RDS manually, we used Elastic Beanstalk and had a production-ready environment running in 20 minutes. The team could focus on shipping features instead of debugging load balancer health checks.


How Elastic Beanstalk Works — Architecture Overview

Let’s break down Elastic Beanstalk’s architecture into digestible pieces. This is the knowledge that’ll help you troubleshoot issues at 2 AM when production is down.

Core Components

1. Application

An Application is the top-level container in Elastic Beanstalk. Think of it as your project or product name — for example, “customer-api” or “payment-service.”

Each application can have multiple versions and environments. You create it once, and it acts as the organizational parent for everything else.

2. Application Versions

Every time you deploy code, Elastic Beanstalk creates an Application Version. This is your ZIP file (or Docker image reference) stored in S3 with a timestamp and label.

Here’s the beautiful part: you can roll back to any previous version instantly. Deployed a bug? Revert to version 1.4.2 with a single click.

3. Environments

An Environment is where your application actually runs. You might have:

  • Dev environment — for testing features
  • Staging environment — for QA validation
  • Production environment — serving real users

Each environment has its own set of AWS resources (EC2 instances, load balancer, security groups). Environments are isolated — changes to dev don’t affect production.

4. Environment Tiers

Elastic Beanstalk offers two types of environments:

  • Web Server Environment — Handles HTTP requests, serves APIs, hosts websites
  • Worker Environment — Processes background jobs from SQS queues

Most applications start with a web server environment. But if you’re processing uploaded images, sending emails, or running batch jobs, you’ll want a worker environment running alongside it.

5. Environment Configuration

Configuration defines how your environment runs:

  • EC2 instance type (t3.micro, c5.large, etc.)
  • Auto Scaling settings (min 2, max 10 instances)
  • Load balancer type (ALB, CLB, NLB)
  • Environment variables (DATABASE_URL, API_KEY)
  • Security groups and VPC settings

The Orchestration Layer

Think of Elastic Beanstalk as a smart conductor orchestrating EC2, ELB, scaling, and deployments behind the scenes.

Here’s what happens when you deploy an application:

  1. You upload your code (ZIP file or Docker image)
  2. Elastic Beanstalk stores the version in S3
  3. It uses CloudFormation to provision resources (EC2, ALB, ASG, security groups)
  4. It configures your instances with the correct runtime (Node.js, Python, Java)
  5. It deploys your application code to EC2 instances
  6. It registers instances with the load balancer
  7. It starts health checks via CloudWatch
  8. It monitors and scales based on traffic

All of this happens automatically. You didn’t write a single CloudFormation template.

Integration with AWS Services

Elastic Beanstalk integrates deeply with:

  • IAM — Instance profiles and service roles control access
  • CloudFormation — Infrastructure provisioning under the hood
  • CloudWatch — Metrics, alarms, and log aggregation
  • S3 — Application version storage
  • EC2 — Compute layer running your app
  • Elastic Load Balancing — Traffic distribution
  • Auto Scaling — Horizontal scaling based on triggers
  • RDS — Optional database provisioning
  • VPC — Network isolation and security

Understanding these connections helps you troubleshoot. If health checks fail, check CloudWatch. If deployments fail, look at CloudFormation events. If permissions break, verify IAM roles.

AWS Elastic Beanstalk Tutorial - the devops tooling
AWS Elastic Beanstalk Tutorial – the devops tooling

Elastic Beanstalk Environments Explained

Environments are where the real work happens. Let me explain the patterns I’ve used in production.

Web Server Environment vs Worker Environment

Web Server Environment:

  • Receives HTTP/HTTPS traffic via a load balancer
  • Runs your API, web app, or frontend
  • Scales based on request load
  • Uses ALB, CLB, or NLB

Worker Environment:

  • Pulls messages from an SQS queue
  • Processes background tasks asynchronously
  • No load balancer (doesn’t serve HTTP)
  • Scales based on queue depth

Real-world scenario: You’re building an e-commerce platform. Your web server environment handles customer checkout requests. When an order is placed, it sends a message to SQS. Your worker environment picks up that message and processes payment confirmation emails, inventory updates, and order fulfillment.

This decouples your request-response flow from long-running tasks, keeping your API fast and responsive.

Blue/Green Deployment Strategy

Here’s a deployment pattern that saved me during a critical production rollout.

Blue/Green Deployment means:

  • Blue environment = current production (version 1.0)
  • Green environment = new version (version 2.0)

You deploy to the green environment, test it, and then swap the URLs. If something breaks, you swap back. Zero downtime. Zero panic.

Step-by-step example:

  1. Production runs on app-prod-blue serving api.mycompany.com
  2. You create app-prod-green and deploy version 2.0
  3. You test app-prod-green at its temporary URL
  4. Everything works — you swap environment URLs
  5. Now app-prod-green serves api.mycompany.com
  6. Traffic switches instantly
  7. If issues arise, swap back to blue

I used this exact pattern when rolling out a breaking API change for a mobile app with 500,000 users. We tested the green environment for 2 hours, then swapped. The switch took 30 seconds. Users didn’t notice a thing.

Reflection Prompt

Think about your current application. When would you choose a worker environment instead of a web server environment?

If you’re processing uploaded videos, generating PDFs, sending bulk emails, or running batch analytics — you need a worker environment. The key is recognizing tasks that shouldn’t block HTTP responses.


Deploying Applications to Elastic Beanstalk

Let’s talk deployment workflows. This is where theory meets practice.

Deployment Methods

1. Console Upload (Manual)

The simplest way: ZIP your code, upload via AWS Console, click deploy. Good for learning, terrible for production.

2. EB CLI (Recommended)

The Elastic Beanstalk CLI is your best friend for real-world deployments.

# Install EB CLI
pip install awsebcli

# Initialize Elastic Beanstalk in your project
eb init -p python-3.11 my-flask-app --region us-east-1

# Create an environment
eb create my-flask-env

# Deploy new code
eb deploy

# Check status
eb status

# View logs
eb logs

# SSH into instance
eb ssh

This workflow lets you version control your deployments and automate from CI/CD pipelines.

3. CI/CD Integration (GitHub Actions, GitLab, Jenkins)

Here’s a GitHub Actions example for automated deployments:

name: Deploy to Elastic Beanstalk

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Generate deployment package
        run: zip -r deploy.zip . -x '*.git*'

      - name: Deploy to EB
        uses: einaregilsson/beanstalk-deploy@v21
        with:
          aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          application_name: my-app
          environment_name: my-app-prod
          version_label: ${{ github.sha }}
          region: us-east-1
          deployment_package: deploy.zip

Every push to main triggers an automatic deployment. That’s how modern DevOps teams ship code.

Supported Platforms

Elastic Beanstalk supports:

  • Node.js (Express, NestJS, Next.js)
  • Python (Django, Flask, FastAPI)
  • Java (Spring Boot, Tomcat)
  • .NET Core (ASP.NET)
  • PHP (Laravel, Symfony)
  • Ruby (Rails, Sinatra)
  • Go
  • Docker (single container or multi-container)

For Docker, you can bring any runtime. I’ve deployed Rust, Elixir, and even legacy PHP 5.6 apps using custom Docker images.

2025 Container Trend: Docker deployments on Elastic Beanstalk have matured significantly. If you’re starting a new project, consider the Docker platform — it gives you complete control over your runtime environment while still benefiting from EB’s auto-scaling and load balancing. Many teams use this as a stepping stone before migrating to ECS or EKS.

Deployment Policies

This is critical. Choose the wrong policy, and you’ll have downtime during deployments.

1. All at Once

  • Deploys to all instances simultaneously
  • Fast but causes downtime
  • Good for: dev environments
  • Bad for: production

2. Rolling

  • Deploys to a few instances at a time
  • No downtime, but reduced capacity during deployment
  • Example: 4 instances, deploy 2 at a time
  • Good for: low-traffic production apps

3. Rolling with Additional Batch

  • Launches extra instances during deployment to maintain capacity
  • No downtime, no performance impact
  • Costs slightly more during deployment
  • Good for: production apps where performance matters

4. Immutable

  • Launches a full set of new instances with the new version
  • Deploys to them, then replaces old instances
  • Safest option, easy rollback
  • Good for: critical production workloads

5. Blue/Green

  • Deploys to an entirely new environment
  • Swaps URLs when ready
  • Complete isolation, zero-downtime
  • Good for: major releases and migrations

My recommendation: Use Immutable for production deployments. Yes, it takes longer, but you get instant rollback and zero risk of partial failures.


Auto Scaling & Load Balancing in Elastic Beanstalk

This is where Elastic Beanstalk shines. Let me show you the scaling logic that keeps your app responsive under traffic spikes.

Auto Scaling Groups (ASGs)

When you create an Elastic Beanstalk environment, it automatically sets up an Auto Scaling Group behind the scenes.

Capacity settings:

  • Minimum instances — The lowest number of EC2 instances running (e.g., 2 for high availability)
  • Maximum instances — The upper limit during traffic spikes (e.g., 10)
  • Desired instances — The target count under normal load

Scaling triggers:

Elastic Beanstalk scales based on metrics like:

  • CPU utilization — Scale out when average CPU > 70% for 5 minutes
  • Network traffic — Scale when network in/out exceeds thresholds
  • Latency — Scale when response times degrade
  • Request count — Scale based on requests per instance

Real-world DevOps scenario:

Imagine you’re running an e-commerce site. Black Friday is coming.

  • Normal traffic: 2 instances handle 500 requests/minute
  • Black Friday traffic: 8,000 requests/minute

Your scaling policy:

Minimum: 2 instances
Maximum: 20 instances
Scale out: CPU > 60% for 5 minutes
Scale in: CPU < 20% for 10 minutes

At 11:59 PM on Thanksgiving, traffic starts spiking. Within 10 minutes, Elastic Beanstalk scales from 2 instances to 15 instances. Your site stays fast. Customers complete orders. Revenue flows.

By 2 AM, traffic drops. Elastic Beanstalk scales back down to 4 instances. You’re not paying for idle capacity.

That’s the power of auto-scaling done right.

Elastic Load Balancing (ALB/CLB/NLB)

Elastic Beanstalk automatically provisions a load balancer for web server environments.

Load balancer types:

  • Application Load Balancer (ALB) — Best for HTTP/HTTPS, supports path-based routing, WebSockets
  • Classic Load Balancer (CLB) — Legacy, still works, but ALB is better
  • Network Load Balancer (NLB) — For ultra-low latency and TCP traffic

Health checks:

Your load balancer pings a health endpoint (e.g., /health or /) every 30 seconds. If an instance fails 3 consecutive checks, it’s marked unhealthy and removed from rotation.

This is why your app must respond to health checks. I’ve debugged deployments where health checks hit /api/health but the route didn’t exist. The load balancer killed every instance, causing a full outage.

Pro tip: Always implement a lightweight health check endpoint that verifies database connectivity and critical dependencies.

# Flask example
@app.route('/health')
def health():
    # Check database
    try:
        db.session.execute('SELECT 1')
        return {'status': 'healthy'}, 200
    except:
        return {'status': 'unhealthy'}, 500

Configuration & Customization

Out-of-the-box, Elastic Beanstalk works great. But production environments always need customization. Here’s how to do it right.

.ebextensions — The Secret Weapon

The .ebextensions folder is where you customize Elastic Beanstalk behavior using YAML configuration files.

Create .ebextensions/ in your project root and add config files like 01-nginx.config or 02-packages.config.

⚠️ YAML Warning: YAML is whitespace-sensitive. Always use spaces, not tabs, when creating .ebextensions files. A single tab character or incorrect indentation will cause deployment failures. Use 2 spaces for indentation consistency.

Example 1: Installing system packages

.ebextensions/packages.config

packages:
  yum:
    git: []
    htop: []
    postgresql-devel: []

This installs Git, htop, and PostgreSQL development libraries on every EC2 instance during deployment.

2025 Platform Note: AWS is transitioning to Amazon Linux 2023 (AL2023), which uses dnf as the package manager (though yum typically aliases to it). If you’re using AL2023 platforms, the syntax remains the same, but you can also use dnf explicitly. Check your Platform Version in the EB Console to confirm whether you’re on Amazon Linux 2 or AL2023.

Example 2: Customizing Nginx

.ebextensions/nginx.config

files:
  "/etc/nginx/conf.d/custom.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
      client_max_body_size 50M;
      proxy_read_timeout 300s;
      proxy_connect_timeout 300s;

container_commands:
  01_reload_nginx:
    command: "sudo service nginx reload"

This increases the max upload size to 50MB and extends proxy timeouts — essential for applications handling file uploads or long-running requests.

Example 3: Environment-specific settings

.ebextensions/environment.config

option_settings:
  aws:elasticbeanstalk:application:environment:
    DATABASE_URL: "postgresql://user:pass@db.example.com/production"
    REDIS_HOST: "redis.example.com"
    LOG_LEVEL: "INFO"

  aws:autoscaling:launchconfiguration:
    InstanceType: t3.medium
    IamInstanceProfile: aws-elasticbeanstalk-ec2-role
    SecurityGroups: sg-0123456789abcdef

This sets environment variables and configures instance type, IAM profile, and security groups.

Customization Options

You can customize:

  • EC2 instance type — Choose compute resources based on workload
  • Security groups — Control inbound/outbound traffic
  • Software packages — Install dependencies via yum, apt, or pip
  • OS-level configurations — Modify kernel parameters, system limits
  • Nginx/Apache reverse proxy — Customize proxy rules, headers, timeouts
  • Environment variables — Pass configuration to your app

The key is understanding that every deployment runs these configurations. If you mess up, every instance gets the broken config. Always test in dev first.


Monitoring, Logging & Troubleshooting

Production systems fail. The question is: how quickly can you diagnose and fix issues?

CloudWatch Metrics

Elastic Beanstalk automatically sends metrics to CloudWatch:

  • Request count — HTTP requests per minute
  • Latency — Average response time
  • HTTP 4xx/5xx errors — Client and server errors
  • CPU utilization — Per-instance processor usage
  • Network in/out — Data transfer metrics
  • Healthy/Unhealthy hosts — Instance health status

Set up CloudWatch alarms:

If EnvironmentHealth = "Red" for 5 minutes → Send SNS notification
If HTTP 5xx > 50 errors/minute → Trigger PagerDuty alert
If Average Latency > 2 seconds → Scale out immediately

Elastic Beanstalk Health Monitoring

Elastic Beanstalk has its own health reporting system:

  • Green — Everything is working perfectly
  • Yellow — Degraded performance, but operational
  • Red — Critical issues, immediate action required
  • Grey — Health status unknown

Enhanced Health Reporting provides deeper insights:

  • Instance-level health status
  • Causes of health degradation
  • Request statistics (5xx, 4xx, latency)
  • Deployment history

Enable it via configuration:

option_settings:
  aws:elasticbeanstalk:healthreporting:system:
    SystemType: enhanced

Log Streaming & Retrieval

Elastic Beanstalk aggregates logs from:

  • Application logs — Your app’s stdout/stderr
  • Web server logs — Nginx or Apache access/error logs
  • Environment logs — Elastic Beanstalk platform events

Retrieve logs via CLI:

# Tail logs in real-time
eb logs --stream

# Download last 100 lines
eb logs

# Download full logs to local file
eb logs --all --zip

Enable log streaming to CloudWatch:

option_settings:
  aws:elasticbeanstalk:cloudwatch:logs:
    StreamLogs: true
    DeleteOnTerminate: false
    RetentionInDays: 7

Now all logs flow to CloudWatch Logs, where you can search, filter, and create metric filters.

Troubleshooting Commands

When things break, here’s my troubleshooting playbook:

# Check environment status
eb status

# View recent events
eb events --follow

# SSH into an instance
eb ssh

# Inside the instance, check logs
sudo tail -f /var/log/eb-activity.log
sudo tail -f /var/log/web.stdout.log
sudo tail -f /var/log/nginx/error.log

# Check running processes
ps aux | grep python
ps aux | grep node

# Verify environment variables
eb printenv

Common issues:

  • Health checks failing — Check your health endpoint, verify it returns 200
  • Deployment stuck — Check CloudFormation events, look for timeout errors
  • 503 errors — All instances unhealthy, check application logs
  • Permission denied — IAM role missing required permissions

Reflection Prompt

How quickly can your team identify when an environment is degraded?

If the answer is “we wait for customers to report issues,” you need better monitoring. Set up CloudWatch alarms and SNS notifications so you’re alerted before users notice problems.


Security Best Practices for Elastic Beanstalk

Security isn’t optional. Here’s how to lock down your Elastic Beanstalk environments.

1. Use IAM Roles, Not Static Credentials

Never embed AWS credentials in your code or environment variables. Instead, attach an IAM instance profile to your EC2 instances.

Example IAM policy for an app accessing S3 and DynamoDB:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:GetObject",
        "s3:PutObject"
      ],
      "Resource": "arn:aws:s3:::my-app-bucket/*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "dynamodb:PutItem",
        "dynamodb:GetItem",
        "dynamodb:Query"
      ],
      "Resource": "arn:aws:dynamodb:us-east-1:123456789012:table/Users"
    }
  ]
}

Attach this policy to aws-elasticbeanstalk-ec2-role, and your application can access S3 and DynamoDB without hardcoded keys.

2. Restrict Instance Profile Permissions

Follow the principle of least privilege. Don’t give your instances full S3 access if they only need to read from one bucket.

3. Use Private Subnets for Backend Workloads

Place your Elastic Beanstalk instances in private subnets with a NAT Gateway for outbound internet access. This prevents direct internet exposure.

Architecture:

Internet → ALB (public subnet) → EC2 instances (private subnet) → RDS (private subnet)

4. Secure ALB with HTTPS

Always use HTTPS in production. Obtain a free SSL certificate from AWS Certificate Manager (ACM) and attach it to your load balancer.

Configuration:

option_settings:
  aws:elbv2:listener:443:
    Protocol: HTTPS
    SSLCertificateArns: arn:aws:acm:us-east-1:123456789012:certificate/abc123

Redirect HTTP to HTTPS:

files:
  "/etc/nginx/conf.d/https_redirect.conf":
    content: |
      server {
        listen 8080;
        return 301 https://$host$request_uri;
      }

5. Encrypt S3 Buckets

Elastic Beanstalk stores application versions in S3. Enable server-side encryption for these buckets.

aws s3api put-bucket-encryption \
  --bucket elasticbeanstalk-us-east-1-123456789012 \
  --server-side-encryption-configuration '{
    "Rules": [{
      "ApplyServerSideEncryptionByDefault": {
        "SSEAlgorithm": "AES256"
      }
    }]
  }'

Additionally, enable S3 Block Public Access to prevent accidental public exposure:

aws s3api put-public-access-block \
  --bucket elasticbeanstalk-us-east-1-123456789012 \
  --public-access-block-configuration \
    "BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true"

This is a critical security compliance requirement for production environments. Many data breaches happen because S3 buckets were accidentally made public.

6. Store Secrets Securely

🚀 Security Tip
Never embed secrets in environment variables. Use AWS Secrets Manager or SSM Parameter Store.

Example: Retrieving secrets at runtime

import boto3

def get_secret(secret_name):
    client = boto3.client('secretsmanager', region_name='us-east-1')
    response = client.get_secret_value(SecretId=secret_name)
    return response['SecretString']

# In your app initialization
db_password = get_secret('prod/db/password')
api_key = get_secret('prod/api/key')

Using SSM Parameter Store:

# Store secret
aws ssm put-parameter \
  --name "/production/database/password" \
  --value "SuperSecretPassword123" \
  --type "SecureString"

# Retrieve in application
import boto3
ssm = boto3.client('ssm')
param = ssm.get_parameter(Name='/production/database/password', WithDecryption=True)
db_password = param['Parameter']['Value']

7. Least Privilege for EB Service Role

The Elastic Beanstalk service role needs permissions to manage resources on your behalf. Use the AWS-managed policy AWSElasticBeanstalkServiceRole, which includes only necessary permissions.


Integrating Elastic Beanstalk with Other AWS Services

Elastic Beanstalk doesn’t exist in isolation. Let’s connect it to the broader AWS ecosystem.

RDS (Relational Database Service)

You can provision an RDS instance directly in Elastic Beanstalk, but don’t do it for production. Here’s why:

When you delete the environment, the RDS instance gets deleted too. That’s data loss.

Better approach: Create RDS separately, then pass the connection string via environment variables.

option_settings:
  aws:elasticbeanstalk:application:environment:
    RDS_HOSTNAME: mydb.c9akciq32.us-east-1.rds.amazonaws.com
    RDS_PORT: 5432
    RDS_DB_NAME: production
    RDS_USERNAME: dbadmin

Store the password in Secrets Manager, not as an environment variable.

S3 (Simple Storage Service)

Common use cases:

  • Store user-uploaded files (profile pictures, documents)
  • Archive application logs
  • Backup application versions

Your application accesses S3 using the instance profile (no hardcoded credentials).

import boto3
s3 = boto3.client('s3')

# Upload file
s3.upload_file('/tmp/upload.jpg', 'my-app-bucket', 'uploads/upload.jpg')

# Generate presigned URL for download
url = s3.generate_presigned_url(
    'get_object',
    Params={'Bucket': 'my-app-bucket', 'Key': 'uploads/upload.jpg'},
    ExpiresIn=3600
)

SNS (Simple Notification Service)

Set up SNS notifications for environment events:

option_settings:
  aws:elasticbeanstalk:sns:topics:
    Notification Topic ARN: arn:aws:sns:us-east-1:123456789012:eb-notifications

Now you get alerts when:

  • Deployments succeed or fail
  • Environment health degrades
  • Auto Scaling events occur

CloudWatch Alarms

Create alarms for proactive monitoring:

aws cloudwatch put-metric-alarm \
  --alarm-name eb-high-cpu \
  --alarm-description "Alert when CPU exceeds 80%" \
  --metric-name CPUUtilization \
  --namespace AWS/EC2 \
  --statistic Average \
  --period 300 \
  --threshold 80 \
  --comparison-operator GreaterThanThreshold \
  --evaluation-periods 2 \
  --alarm-actions arn:aws:sns:us-east-1:123456789012:devops-alerts

CodePipeline CI/CD

Integrate Elastic Beanstalk into a full CI/CD pipeline:

CodeCommit (source) → CodeBuild (test & build) → CodeDeploy/Elastic Beanstalk (deploy) → Production

Pipeline configuration:

  1. Code pushed to CodeCommit
  2. CodeBuild runs tests and creates deployment package
  3. Elastic Beanstalk deploys to staging environment
  4. Manual approval gate
  5. Elastic Beanstalk deploys to production

ECR (Elastic Container Registry)

If you’re deploying Docker containers, store images in ECR and reference them in your Dockerrun.aws.json:

{
  "AWSEBDockerrunVersion": "1",
  "Image": {
    "Name": "123456789012.dkr.ecr.us-east-1.amazonaws.com/my-app:latest",
    "Update": "true"
  },
  "Ports": [
    {
      "ContainerPort": 8000
    }
  ]
}

Route53 (DNS Management)

Point your custom domain to Elastic Beanstalk:

  1. Create a CNAME record pointing api.mycompany.com to your EB environment URL
  2. Or use an alias record for the root domain
Type: A
Name: mycompany.com
Alias: Yes
Alias Target: myapp-env.us-east-1.elasticbeanstalk.com

Real-World Integration Example

Scenario: Deploying a Python Flask app on Elastic Beanstalk with RDS MySQL and S3 backup.

Architecture:

Internet → Route53 → ALB (HTTPS) → Elastic Beanstalk (Flask app) → RDS MySQL
                                                                     ↓
                                                                  S3 (backups)

Steps:

  1. Create RDS MySQL instance (separate from EB)
  2. Create S3 bucket for database backups
  3. Deploy Flask app to Elastic Beanstalk
  4. Pass RDS endpoint as environment variable
  5. Use IAM role to grant S3 access
  6. Configure automated backups to S3
  7. Set up CloudWatch alarms for errors and latency
  8. Configure Route53 to point custom domain to ALB

This architecture is production-ready, scalable, and follows AWS best practices.


Common Elastic Beanstalk Mistakes to Avoid

I’ve seen these mistakes cost teams hours of debugging and, in some cases, data loss. Learn from them.

1. Leaving RDS Inside Elastic Beanstalk Lifecycle

Mistake: Creating an RDS instance through Elastic Beanstalk environment configuration.

Why it’s bad: When you delete the environment (or it gets terminated accidentally), your database is deleted too. All data gone.

Solution: Always create RDS separately and connect via environment variables.

2. Using All-at-Once Deployments in Production

Mistake: Deploying with “All at once” policy to production.

Why it’s bad: All instances go down simultaneously during deployment. Your app has downtime.

Solution: Use Immutable or Rolling with additional batch for production. Accept the slightly longer deployment time for zero downtime.

3. Overlooking Instance Profile Permissions

Mistake: Forgetting to attach necessary IAM permissions to the instance profile.

Why it’s bad: Your app can’t access S3, DynamoDB, or other AWS services. You get cryptic “Access Denied” errors.

Solution: Always verify IAM permissions during initial setup. Test in dev first.

4. Misconfiguring Environment Variables

Mistake: Typos in environment variable names or storing secrets directly in environment variables.

Why it’s bad: Your app crashes on startup, or worse, secrets get logged and exposed.

Solution: Use Secrets Manager for sensitive data. Double-check variable names in .ebextensions or console.

5. Ignoring Health Warnings

Mistake: Seeing “Yellow” or “Red” health status and ignoring it because the app still responds.

Why it’s bad: Degraded health often indicates underlying issues (high CPU, failed instances, timeouts). Ignoring it leads to eventual outages.

Solution: Investigate immediately. Use eb health --refresh to get real-time status.

6. Storing Application Versions Indefinitely

Mistake: Never cleaning up old application versions in S3.

Why it’s bad: You accumulate hundreds of 50MB ZIP files, increasing S3 costs and clutter.

Solution: Enable application version lifecycle policy to automatically delete old versions:

option_settings:
  aws:elasticbeanstalk:application:
    Application Healthcheck URL: /health
  aws:elasticbeanstalk:application:lifecycle:
    MaxCountRule: "25"
    DeleteSourceFromS3: true

This keeps only the 25 most recent versions and deletes older ones from S3.

7. Not Testing .ebextensions Changes

Mistake: Deploying untested .ebextensions configurations directly to production.

Why it’s bad: Syntax errors or incorrect commands can break deployments, causing full outages.

Solution: Test configuration changes in dev environment first. Use eb config save to backup configurations.


Elastic Beanstalk Pricing Notes

Let’s talk money. Elastic Beanstalk is often described as “free,” but there’s nuance here.

Elastic Beanstalk itself is free. You don’t pay for the platform.

But you pay for the underlying AWS resources:

  • EC2 instances — Based on instance type and running hours
  • Elastic Load Balancing — ALB charges per hour + per processed GB
  • Auto Scaling — No additional charge (just the EC2 instances)
  • RDS — If you provision a database
  • S3 — For application version storage
  • CloudWatch — If you exceed free tier (logs, metrics, alarms)
  • Data transfer — Outbound data transfer charges

Cost estimation example:

Small production environment (approximate us-east-1 pricing):

  • 2 x t3.medium instances (on-demand) = ~$60/month
  • Application Load Balancer = ~$20/month
  • RDS db.t3.micro = ~$15/month
  • S3 storage (10GB) = ~$0.23/month
  • Data transfer (100GB/month) = ~$9/month

Total: ~$104/month

Pricing Note: These are approximate costs for us-east-1 region as of 2025. Pricing varies by region and fluctuates over time. Always use the AWS Pricing Calculator for accurate estimates: https://calculator.aws

Real-world cost warning:

I once consulted for a team that chose t3.xlarge instances (4 vCPUs, 16GB RAM) for a dev environment that saw maybe 10 requests per day. They were paying $240/month for idle capacity that was completely unnecessary.

We switched to t3.micro (2 vCPUs, 1GB RAM) for dev and saved $220/month — over $2,600 annually. The performance was identical for their low-traffic development workload.

Lesson: Always right-size your instances based on actual usage. Use CloudWatch metrics to track CPU and memory utilization. If you’re consistently under 20% utilization, you’re overpaying.

Cost optimization tips:

  • Use Savings Plans or Reserved Instances for production environments
  • Use Spot Instances for non-critical workloads (EB supports this!)
  • Set appropriate Auto Scaling min/max limits
  • Delete old application versions to reduce S3 costs
  • Use CloudWatch Logs retention policies to avoid accumulating logs forever

🚀 2025 Pro Tip: Switch to Graviton Instances

Consider using t4g instances (AWS Graviton processors) instead of t3 for your Web Server Environments. Graviton-based instances offer up to 40% better price-performance for Python, Node.js, Ruby, and containerized applications.

Example cost comparison:

  • t3.medium = ~$30/month
  • t4g.medium = ~$24/month (20% cheaper with better performance)

Graviton support is mature in 2025 — most platforms (Python 3.11+, Node.js 18+, Docker) work seamlessly. Always test in dev first, but the savings are real.

Budget alert setup:

aws budgets create-budget \
  --account-id 123456789012 \
  --budget file://budget.json \
  --notifications-with-subscribers file://notifications.json

Set a monthly budget alert (e.g., $150/month) and get notified if costs exceed 80%.


Conclusion & Next Steps

Elastic Beanstalk allows you to focus on your application — not the servers. But understanding how it works under the hood is what separates beginners from DevOps engineers.

You’ve now learned:

  • The architecture and components of Elastic Beanstalk
  • How to deploy applications with confidence
  • Environment management strategies for zero-downtime releases
  • Auto-scaling and load balancing mechanics
  • Security best practices for production workloads
  • Integration patterns with RDS, S3, CloudWatch, and other AWS services
  • Common mistakes that even experienced teams make

The next step is hands-on practice. Theory only gets you so far — you need to deploy real applications, break things, troubleshoot, and learn from failures.

Here’s your challenge: Deploy a simple Node.js or Python application to Elastic Beanstalk this week. Use the EB CLI, set up auto-scaling, configure environment variables, and monitor health in CloudWatch. Then break it intentionally — deploy bad code, misconfigure health checks, exceed instance capacity — and learn to recover.

That’s how you build real expertise.

👉 Ready to Go Deeper?

Take the Free AWS Elastic Beanstalk Crash Course and learn how to deploy and scale applications hands-on.Start Learning Now


Frequently Asked Questions (FAQs)

What is AWS Elastic Beanstalk?

AWS Elastic Beanstalk is a Platform-as-a-Service (PaaS) that automates the deployment, scaling, and management of web applications. It provisions EC2 instances, load balancers, auto-scaling groups, and monitoring while letting developers focus on writing code rather than managing infrastructure.

Is AWS Elastic Beanstalk free?

Elastic Beanstalk itself is free — you don’t pay for the platform. However, you pay for the underlying AWS resources it provisions, including EC2 instances, load balancers, RDS databases, and S3 storage. Costs vary based on instance types and configuration.

How does Elastic Beanstalk deployment work?

Elastic Beanstalk deployment works by uploading your application code (as a ZIP file or Docker image) to the platform. It then provisions EC2 instances, installs the necessary runtime environment, deploys your code, and configures load balancing and auto-scaling automatically. You can deploy using the AWS Console, EB CLI, or CI/CD pipelines.

What are Elastic Beanstalk environments?

Environments are where your application runs. Each environment has its own set of AWS resources (EC2 instances, load balancer, security groups). You can have multiple environments for dev, staging, and production. Elastic Beanstalk supports two environment types: Web Server Environments (for HTTP traffic) and Worker Environments (for background job processing).

Is Elastic Beanstalk good for production?

Yes, Elastic Beanstalk is production-ready when configured correctly. Many companies use it for high-traffic applications. The key is using proper deployment policies (Immutable or Blue/Green), configuring auto-scaling appropriately, setting up monitoring with CloudWatch, and following security best practices like using IAM roles, HTTPS, and private subnets.

What’s the difference between Elastic Beanstalk and EC2?

Elastic Beanstalk is a managed platform that automatically provisions and configures EC2 instances, load balancers, and scaling for you. EC2 is a raw compute service where you manually configure everything. Elastic Beanstalk is faster to set up and better for standard web applications, while EC2 gives you complete control for custom infrastructure requirements.

Can I use Docker with Elastic Beanstalk?

Yes, Elastic Beanstalk fully supports Docker deployments. You can deploy single-container or multi-container Docker applications. This allows you to use any programming language or runtime by packaging it in a Docker image.

How do I roll back a deployment in Elastic Beanstalk?

Rolling back is simple: navigate to your environment in the AWS Console, go to “Application versions,” select a previous version, and click “Deploy.” With the EB CLI, use eb deploy --version <version-label>. If you use Blue/Green deployments, you can simply swap environment URLs back to the previous version.


Mini Quiz — Test Your Knowledge

Question 1: You’re deploying a critical production update to an e-commerce API serving 10,000 requests per minute. Which deployment policy should you choose and why?
Click to reveal answer

Answer: Immutable deployment

Why? Immutable deployment launches a completely new set of instances with the updated code, then replaces the old instances. This ensures zero downtime and provides instant rollback capability if something goes wrong. For critical production workloads, the extra deployment time is worth the safety and reliability.

Rolling or Rolling with Additional Batch could work, but Immutable provides the cleanest rollback mechanism. Never use All-at-Once for production — that causes downtime.


Question 2: Your Elastic Beanstalk environment shows “Red” health status. You SSH into an instance and find the application is running fine. What’s the most likely cause?
Click to reveal answer

Answer: Health check endpoint failure

The most common cause of health check failures is that the load balancer is pinging a health endpoint (like /health or /) that either doesn’t exist, returns a non-200 status code, or times out. Even though your application runs, if it doesn’t respond correctly to health checks, the load balancer marks instances as unhealthy.

Solution: Verify your health check path in the load balancer configuration and ensure your application responds with a 200 OK status.


Final Reflection Prompt:

Think about an application you’re currently working on or planning to build. Could Elastic Beanstalk simplify your deployment process? What trade-offs would you need to consider — control versus convenience, customization versus automation?

The best DevOps engineers know when to use managed services like Elastic Beanstalk and when to build custom infrastructure with Terraform or CloudFormation. There’s no one-size-fits-all answer — only the right tool for the right job.


About the Author

Srikanth Ch is a Senior DevOps Engineer and founder of thedevopstooling.com, a comprehensive DevOps learning platform helping engineers master AWS, Kubernetes, CI/CD, and modern infrastructure practices. With years of production experience deploying and scaling applications on AWS, Srikanth shares practical, real-world knowledge that goes beyond theory.

Tags: #AWS #ElasticBeanstalk #DevOps #CloudComputing #AWSSAA #PlatformAsAService #AutoScaling #LoadBalancing #CloudFormation #AWSArchitecture

Last Updated: November 2025

Similar Posts

Leave a Reply