Skip to content

Platform_services

Chapter 10: AWS Elastic Beanstalk & App Runner

Section titled “Chapter 10: AWS Elastic Beanstalk & App Runner”

Simplified Application Deployment Platforms

Section titled “Simplified Application Deployment Platforms”

AWS provides platform services that simplify application deployment, reducing the operational overhead of managing infrastructure.

AWS Platform Services
+------------------------------------------------------------------+
| |
| +------------------------+ |
| | Platform Services | |
| +------------------------+ |
| | |
| +---------------------+---------------------+ |
| | | | |
| v v v |
| +----------+ +----------+ +----------+ |
| | Elastic | | App | | Lightsail| |
| |Beanstalk | | Runner | | | |
| | | | | | | |
| | Full | | Container| | Simple | |
| | Control | | Native | | VPS/ | |
| | PaaS | | Serverless| | Containers| |
| +----------+ +----------+ +----------+ |
| |
| Elastic Beanstalk: Traditional apps with full control |
| App Runner: Modern containerized apps, fully managed |
| Lightsail: Simple, predictable pricing for small projects |
| |
+------------------------------------------------------------------+

Elastic Beanstalk Architecture
+------------------------------------------------------------------+
| |
| +------------------------+ |
| | Elastic Beanstalk | |
| | Application | |
| +------------------------+ |
| | |
| +---------------------+---------------------+ |
| | | | |
| v v v |
| +----------+ +----------+ +----------+ |
| |Environment| | Versions | | Configs | |
| +----------+ +----------+ +----------+ |
| |
| Environment: Collection of AWS resources |
| Versions: Deployable application code |
| Configs: Environment settings and options |
| |
+------------------------------------------------------------------+
Elastic Beanstalk Environment Tiers
+------------------------------------------------------------------+
| |
| Web Server Environment |
| +----------------------------------------------------------+ |
| | | |
| | Internet | |
| | | | |
| | v | |
| | +----------+ +----------+ +----------+ | |
| | |Route 53/ | | ALB | | EC2 | | |
| | |CloudFront|---->|(Load |---->| Instances| | |
| | +----------+ |Balancer)| +----------+ | |
| | +----------+ | | |
| | v | |
| | +----------+ | |
| | | RDS | | |
| | | Database | | |
| | +----------+ | |
| | | |
| | Use Case: Web applications, APIs | |
| | Scaling: Auto Scaling enabled | |
| +----------------------------------------------------------+ |
| |
| Worker Environment |
| +----------------------------------------------------------+ |
| | | |
| | SQS Queue | |
| | +----------+ | |
| | | Messages | | |
| | +----------+ | |
| | | | |
| | v | |
| | +----------+ +----------+ | |
| | | Worker | | EC2 | | |
| | | Daemon |---->| Instances| | |
| | +----------+ +----------+ | |
| | | |
| | Use Case: Background processing, scheduled tasks | |
| | Scaling: Based on queue depth | |
| +----------------------------------------------------------+ |
| |
+------------------------------------------------------------------+
Elastic Beanstalk Platforms
+------------------------------------------------------------------+
| |
| Platform | Versions |
| ----------------------|---------------------------------------|
| Node.js | 12, 14, 16, 18 |
| Python | 3.7, 3.8, 3.9, 3.10, 3.11 |
| Java | 8, 11, 17 |
| .NET | 6.0, 7.0 |
| PHP | 7.4, 8.0, 8.1, 8.2 |
| Ruby | 2.7, 3.0, 3.1, 3.2 |
| Go | 1.18, 1.19, 1.20 |
| Docker | Multi-container (ECS) |
| Tomcat | 8.5, 9.0 |
| |
+------------------------------------------------------------------+
Elastic Beanstalk Deployment Policies
+------------------------------------------------------------------+
| |
| 1. All at Once |
| +----------------------------------------------------------+ |
| | | |
| | Old Version New Version | |
| | +----+ +----+ +----+ +----+ +----+ +----+ | |
| | | I1 | | I2 | | I3 | | I1 | | I2 | | I3 | | |
| | +----+ +----+ +----+ +----+ +----+ +----+ | |
| | | | | | | | | |
| | +------+------+ +------+------+ | |
| | | | | |
| | v v | |
| | [Downtime] [All new at once] | |
| | | |
| | Pros: Fastest deployment | |
| | Cons: Downtime during deployment | |
| +----------------------------------------------------------+ |
| |
| 2. Rolling |
| +----------------------------------------------------------+ |
| | | |
| | Batch 1: Batch 2: Batch 3: | |
| | +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+
| | |New | |Old | |Old | |New | |New | |Old | |New | |New | |New |
| | +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+
| | | |
| | Pros: No downtime, gradual rollout | |
| | Cons: Mixed versions during deployment | |
| +----------------------------------------------------------+ |
| |
| 3. Rolling with Additional Batch |
| +----------------------------------------------------------+ |
| | | |
| | Old: 3 instances | |
| | New: 4 instances (temporary) | |
| | | |
| | Pros: Full capacity during deployment | |
| | Cons: Additional cost during deployment | |
| +----------------------------------------------------------+ |
| |
| 4. Immutable |
| +----------------------------------------------------------+ |
| | | |
| | Old Environment New Environment | |
| | +----+ +----+ +----+ +----+ +----+ +----+ | |
| | | I1 | | I2 | | I3 | | I4 | | I5 | | I6 | | |
| | +----+ +----+ +----+ +----+ +----+ +----+ | |
| | | |
| | Pros: Safest, easy rollback | |
| | Cons: Slowest, highest cost | |
| +----------------------------------------------------------+ |
| |
| 5. Blue/Green |
| +----------------------------------------------------------+ |
| | | |
| | Blue Environment Green Environment | |
| | (Current) (New Version) | |
| | +----+ +----+ +----+ +----+ +----+ +----+ | |
| | | I1 | | I2 | | I3 | | I4 | | I5 | | I6 | | |
| | +----+ +----+ +----+ +----+ +----+ +----+ | |
| | | |
| | Switch: Route 53 or swap CNAMEs | |
| | | |
| | Pros: Instant rollback, full testing | |
| | Cons: Double resources during transition | |
| +----------------------------------------------------------+ |
| |
+------------------------------------------------------------------+
.ebextensions/options.config
option_settings:
aws:autoscaling:asg:
MinSize: 2
MaxSize: 10
Cooldown: 300
aws:autoscaling:launchconfiguration:
InstanceType: t3.medium
IamInstanceProfile: ec2-role
EC2KeyName: my-key-pair
aws:elb:listener:443:
ListenerProtocol: HTTPS
InstancePort: 80
SSLCertificateId: arn:aws:acm:us-east-1:123456789012:certificate/abc123
aws:elasticbeanstalk:application:environment:
ENVIRONMENT: production
DB_TABLE: users
aws:elasticbeanstalk:healthreporting:system:
SystemType: enhanced
aws:elasticbeanstalk:managedactions:platformupdate:
UpdateLevel: minor
InstanceRefreshEnabled: true
# .ebextensions/nginx.config
files:
"/etc/nginx/conf.d/proxy.conf":
mode: "000644"
owner: root
group: root
content: |
upstream nodejs {
server 127.0.0.1:8081;
keepalive 256;
}
server {
listen 8080;
location / {
proxy_pass http://nodejs;
proxy_set_header Connection "";
proxy_http_version 1.1;
}
}

App Runner Architecture
+------------------------------------------------------------------+
| |
| +------------------------+ |
| | App Runner | |
| | Service | |
| +------------------------+ |
| | |
| +---------------------+---------------------+ |
| | | | |
| v v v |
| +----------+ +----------+ +----------+ |
| | Source | | Build | | Deploy | |
| | | | | | | |
| | - ECR | | - Auto | | - Auto | |
| | - GitHub | | Build | | Scale | |
| | - Code | | | | | |
| +----------+ +----------+ +----------+ |
| |
| Fully managed container service |
| Automatic builds and deployments |
| Built-in load balancing and encryption |
| |
+------------------------------------------------------------------+
App Runner Key Features
+------------------------------------------------------------------+
| |
| 1. Source Options |
| +----------------------------------------------------------+ |
| | | |
| | Container Image (ECR) | |
| | - Pre-built Docker image | |
| | - Manual or automatic deployments | |
| | | |
| | Source Code (GitHub) | |
| | - Connect GitHub repository | |
| | - Automatic builds on push | |
| | - App Runner builds the container | |
| +----------------------------------------------------------+ |
| |
| 2. Automatic Scaling |
| +----------------------------------------------------------+ |
| | | |
| | Min instances: 1 (default) | |
| | Max instances: 25 (default, adjustable) | |
| | | |
| | Scaling metric: | |
| | - Concurrent requests per instance | |
| | - Default: 100 concurrent requests | |
| | | |
| | Scale out: When concurrent requests exceed threshold | |
| | Scale in: When traffic decreases | |
| +----------------------------------------------------------+ |
| |
| 3. Built-in Features |
| +----------------------------------------------------------+ |
| | | |
| | - Load balancer (automatic) | |
| | - TLS/SSL (automatic) | |
| | - Custom domain support | |
| | - Health checks | |
| | - Logging to CloudWatch | |
| | - VPC access (optional) | |
| +----------------------------------------------------------+ |
| |
+------------------------------------------------------------------+
{
"ServiceName": "my-app",
"SourceConfiguration": {
"AuthenticationConfiguration": {
"ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection"
},
"AutoDeploymentsEnabled": true,
"CodeRepository": {
"RepositoryUrl": "https://github.com/myorg/myapp",
"SourceCodeVersion": {
"Type": "BRANCH",
"Value": "main"
},
"CodeConfiguration": {
"ConfigurationSource": "API",
"CodeConfigurationValues": {
"Runtime": "PYTHON_311",
"BuildCommand": "pip install -r requirements.txt",
"StartCommand": "python app.py",
"Port": "8080",
"RuntimeEnvironmentVariables": {
"ENVIRONMENT": "production"
}
}
}
}
},
"InstanceConfiguration": {
"Cpu": "1024",
"Memory": "2048",
"InstanceRoleArn": "arn:aws:iam::123456789012:role/AppRunnerRole"
},
"HealthCheckConfiguration": {
"Protocol": "HTTP",
"Path": "/health",
"IntervalInSeconds": 10,
"TimeoutInSeconds": 5,
"HealthyThreshold": 3,
"UnhealthyThreshold": 5
}
}

10.4 Comparison: Elastic Beanstalk vs App Runner

Section titled “10.4 Comparison: Elastic Beanstalk vs App Runner”
Platform Service Comparison
+------------------------------------------------------------------+
| |
| Feature | Elastic Beanstalk | App Runner |
| ---------------------|-------------------|---------------------|
| Infrastructure | EC2 instances | Fully managed |
| Control | Full access | Limited |
| SSH Access | Yes | No |
| Custom AMI | Yes | No |
| ---------------------|-------------------|---------------------|
| Deployment | Multiple policies | Automatic |
| Rollback | Manual/Auto | Automatic |
| Blue/Green | Yes | No |
| ---------------------|-------------------|---------------------|
| Scaling | Auto Scaling | Built-in |
| Load Balancer | ALB/NLB | Built-in |
| SSL/TLS | Configure | Automatic |
| ---------------------|-------------------|---------------------|
| Database | RDS integration | External only |
| VPC Access | Full | Optional |
| ---------------------|-------------------|---------------------|
| Use Case | Traditional apps | Containerized apps |
| Complexity | Medium | Low |
| Pricing | EC2 + services | Per-instance |
| |
+------------------------------------------------------------------+

Terminal window
# Initialize EB CLI
eb init --region us-east-1
# Create environment
eb create production --env-tier webserver --instance-type t3.medium
# Deploy new version
eb deploy production
# Open application in browser
eb open
# Check environment status
eb status production
# View logs
eb logs production
# Set environment variables
eb setenv DB_TABLE=users LOG_LEVEL=INFO
# Create blue/green deployment
eb clone production production-v2
# Swap environment URLs
eb swap production-v2 --destination-name production
# Terminate environment
eb terminate production
Terminal window
# Create service from ECR
aws apprunner create-service \
--service-name my-app \
--source-configuration '{"ImageRepository":{"ImageIdentifier":"123456789012.dkr.ecr.us-east-1.amazonaws.com/my-app:latest","ImageRepositoryType":"ECR"}}' \
--instance-configuration '{"Cpu":"1024","Memory":"2048"}'
# Create service from GitHub
aws apprunner create-service \
--service-name my-app \
--source-configuration file://source-config.json
# Update service
aws apprunner update-service \
--service-arn arn:aws:apprunner:us-east-1:123456789012:service/my-app/abc123 \
--source-configuration '{"AutoDeploymentsEnabled":true}'
# Start deployment
aws apprunner start-deployment \
--service-arn arn:aws:apprunner:us-east-1:123456789012:service/my-app/abc123
# Describe service
aws apprunner describe-service \
--service-arn arn:aws:apprunner:us-east-1:123456789012:service/my-app/abc123
# Delete service
aws apprunner delete-service \
--service-arn arn:aws:apprunner:us-east-1:123456789012:service/my-app/abc123

Platform Services Best Practices
+------------------------------------------------------------------+
| |
| Elastic Beanstalk |
| +----------------------------------------------------------+ |
| | 1. Use .ebextensions for configuration | |
| | 2. Use immutable deployments for production | |
| | 3. Enable enhanced health reporting | |
| | 4. Use managed platform updates | |
| | 5. Configure proper IAM roles | |
| | 6. Use Blue/Green for zero-downtime deployments | |
| +----------------------------------------------------------+ |
| |
| App Runner |
| +----------------------------------------------------------+ |
| | 1. Use health check endpoints | |
| | 2. Configure appropriate instance size | |
| | 3. Use VPC connector for private resources | |
| | 4. Enable auto-deployments for CI/CD | |
| | 5. Use Secrets Manager for sensitive data | |
| | 6. Configure custom domains with TLS | |
| +----------------------------------------------------------+ |
| |
+------------------------------------------------------------------+

Exam Tip

  1. Elastic Beanstalk: PaaS for traditional applications, full control
  2. App Runner: Serverless containers, fully managed
  3. Deployment Policies: All-at-once (fastest), Rolling (gradual), Immutable (safest)
  4. Blue/Green: Separate environments, instant switch
  5. .ebextensions: Configuration files in application source
  6. Worker Environments: Background processing with SQS
  7. App Runner Scaling: Based on concurrent requests
  8. Platform Updates: Managed updates for security patches

Chapter 11: Amazon VPC - Virtual Private Cloud


Last Updated: February 2026