Code on GitHub

What

This website (davidtschneider.com), hosted using AWS. I use it to show off whatever I happen to be working on in my spare time.

Why

The previous version of this site used Flask and nginx on a Raspberry Pi. I wanted it off my network (especially given the pain of DHCP on home WiFi) without paying for a server to babysit. It also presents a unique AWS challenge for me: I’ve worked with plenty of enterprises to help reduce large bills, but what makes a dent in my wallet is a lot different than theirs. This project takes frugality to the extreme - I’d rather it go down for a few days than a hefty bill, especially since it doesn’t have “customers”/users.

I don’t recommend this setup for “production” applications, but I’ve found it to work for me.

How

Architecture diagram: a visitor resolves the site through Route 53 and reaches CloudFront, where AWS WAF and CloudFront Functions sit in front of a private S3 bucket reached by Origin Access Control. GitHub Actions assumes an IAM deploy role over OIDC to sync the bucket and invalidate CloudFront. A flood brake runs from a CloudWatch alarm on WAF request counts, through SNS, to a Lambda that sets WAF to block all.

Build. A small Python script uses Jinja2 to turn Markdown files with YAML front matter into HTML. Assets get content-hashed filenames, so everything can be cached for a year. Self-contained apps, like the other projects in my portfolio, are vendored in as pre-built static files.

Serving. The HTML lives in a private S3 bucket that only CloudFront can read (Origin Access Control). Route 53 provides DNS, and ACM provides the TLS certificate. Two small CloudFront Functions run at the edge:

  • One redirects www and old-site URLs, and appends index.html to directory requests. A private S3 origin has no default document, so without it /resume/ would return a 403.
  • One sets the Content-Security-Policy and Permissions-Policy headers, which the flat-rate plan’s managed header policies don’t offer.

Cost control. CloudFront’s flat-rate Free plan bundles WAF, DDoS protection, the certificate and the DNS zone, with no overage charges. A viral link or a determined attacker makes for a slow month, not a surprise bill. Behind that sits a “flood brake”: a CloudWatch alarm on WAF request counts notifies me over SNS and triggers a Lambda that flips the WAF to block everything, for traffic that neither the plan nor my budget would cover. Budget alerts at the project and account level catch the more likely culprit, a configuration mistake.

Infrastructure and deploys. All of it is Terraform, mostly so I remember how it works the next time I touch it. A push to main runs GitHub Actions, which builds the site, runs the tests and secret scan, and syncs the result to S3 before invalidating CloudFront. It authenticates to AWS with OIDC and a narrowly scoped IAM role, so there are no AWS keys stored anywhere.

Cost Breakdown

Roughly what each service adds to my monthly bill:

Service In Diagram Monthly cost Comments
Route 53 (DNS) ✅ $0 Hosted zones are usually $0.50/month, but CloudFront flat-rate plan gives 1 freebie.
WAF ✅ $0 Normally $5/month (ACL) plus $1 per rule. Flat-rate plan includes 1 free ACL and 5 free rules.
CloudFront Functions ✅ $0 Included in the plan.
CloudFront ✅ $0 Free tier, with no overage charges however much traffic arrives.
S3 (private bucket) ✅ $0 The site is a few megabytes - cost is fractions of a cent.
CloudWatch alarm ✅ $0 Less then 10 standard alarms, so within free tier.
SNS ✅ $0 A handful of emails a year, inside the free tier.
Lambda ✅ $0 Runs only when the brake trips, so usage never goes above the free tier limit.
IAM role and GitHub Actions ✅ $0 IAM is free, Actions minutes are included with my account.
DNSSEC signing key (KMS) ~$1.00 Bit the bullet on this one for security.
Domain registration ~$1.70 ~$20/year.
Total N/A ~$2.70 ~100% registration and KMS key.