Secure Cloud Deployment: A Field Book¶
Django · PostgreSQL · Redis · Celery · Docker Compose · nginx · AWS (EC2, RDS)
Personal knowledge book. First written December 2026, after investigating a real compromise of a staging and production setup built by someone else. Every rule in here exists because its absence caused real damage.
Note
AWS console paths, defaults and limits were checked against the official AWS documentation in December 2026 (see Appendix C). AWS renames console labels from time to time: if a screen doesn't match, follow the meaning of the step, and re-check the linked documentation.
Table of contents¶
| # | Chapter | What it gives you |
|---|---|---|
| 1 | Lessons from a real incident | What went wrong, why, and the rule each mistake produced |
| 2 | Prerequisites | Skills, accounts, permissions, tools and decisions needed before you start |
| 3 | Rules and hazards | 14 non-negotiable rules, and 22 hazards with how to detect and prevent each |
| 4 | AWS account baseline | Identity, logging, alerting and secure defaults, once per account |
| 5 | Network and security groups | Layout, named security groups, changing rules without downtime |
| 6 | The EC2 server | Launching the instance field by field, OS hardening, Docker, Session Manager |
| 7 | The database (RDS PostgreSQL) | Subnet group, parameter group, every create-database field, the app role |
| 8 | Application and containers | Django production settings, per-server compose files, self-hosted Postgres, secrets |
| 9 | nginx and TLS | Reverse proxy, certificates, redirects, security headers |
| 10 | Deployment | First deployment in 10 steps, routine deployments, rollback |
| 11 | Verification | The checks after every infrastructure change |
| 12 | Operations | Backups, monitoring, patching, the monthly audit |
| 13 | Auditing an inherited setup | How to examine infrastructure someone else built, before trusting it |
| 14 | Incident response | What not to do, evidence, containment, investigation, recovery |
| A | Go-live checklist | One page, tick every box |
| B | Quick commands | The commands used most often |
| C | Sources | Official documentation behind the AWS/Docker facts |
| — | tools/ | Read-only triage script for a Docker host, read-only RDS check |
How to read it¶
| Situation | Path |
|---|---|
| New project / new AWS account | 2 → 4 → 5 → 6 → 7 → 8 → 9 → 10 → 11 |
| Deploying an update | 10 (routine deployment) → 11 (quick checks) |
| Taking over someone else's setup | 13 first, then fix with 4–9 |
| Something looks compromised | 14, before touching anything |
| Monthly | 12 (monthly audit) |
| Quarterly | Re-read 1 and 3 |
Conventions used in this book¶
| Placeholder | Meaning |
|---|---|
<project> |
short project name, lowercase, e.g. shop |
<env> |
prod or staging |
<domain> |
the site's domain name |
<office IP> |
your office's fixed public IPv4 address |
<rds-endpoint> |
the RDS endpoint hostname |
| [AWS] / [server] / [laptop] | where a step is performed |