Deploying to AWS EC2
An EC2 deployment is a classic “you manage the server” approach.
High-level architecture
Section titled “High-level architecture”- EC2 instance (Linux)
- Gunicorn runs your app as a systemd service
- Nginx reverse proxies from port 80/443 to Gunicorn
flowchart LR Internet --> SG[Security Group] SG --> N[Nginx :80/:443] N --> G[Gunicorn :8000] G --> App[Flask]
Key pieces to understand
Section titled “Key pieces to understand”- Security groups (open ports 80/443)
- SSH access
- systemd service files
- Nginx site config
- TLS certificates (Let’s Encrypt)
Typical deployment approach
Section titled “Typical deployment approach”- configure environment variables (systemd service)
- start/restart service on code changes
- log to journald (systemctl logs)
Operational caution
Section titled “Operational caution”EC2 gives you full control but also full responsibility:
- patching OS
- firewall rules
- backups
- monitoring
It’s great for learning real-world deployment fundamentals.
pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading