TkMWorks techbytes

TechBytes

How this blog is built

Markdown in a private CodeCommit repository, turned into static pages by CodeBuild and shipped to S3 and CloudFront by the same build-agent pipeline that runs the rest of tkmworks.co.in.

TechBytes is the fourth site under tkmworks.co.in, after the landing page, the apps page and the websites portal. It’s also the simplest one, on purpose: no server, no database, no CMS. Just files.

This post walks through how a post goes from a Markdown file on my laptop to a page you can read, and why each piece is there.

Writing a post#

Each post is a folder in a private CodeCommit repository, holding an index.md and any images it uses. The file starts with a few lines of front matter:

---
title: How this blog is built
date: 2026-11-25
summary: One or two sentences for the list, the feed and link previews.
tags: [aws, cloudfront]
draft: true
---

While draft is true, the post is skipped when the site is built for publishing. I can still preview it locally with python3 scripts/build.py --drafts.

From Markdown to pages#

When I push to main, a CodePipeline in the CICD account starts. Its Validate stage is a CodeBuild job that:

  1. runs the generator’s unit tests,
  2. lints the CloudFormation template with cfn-lint,
  3. turns every post into HTML with Python-Markdown and Pygments, and
  4. checks that every link and image in the output points at a real file.

The generator is a single Python script of under 500 lines. It writes one index.html per page, so the URLs stay clean: /posts/how-this-blog-is-built/, not /posts/how-this-blog-is-built.html. It also writes an Atom feed, a sitemap and a 404 page.

Build once, deploy once#

The rest is the same build-agent pattern as every other site here:

Stage What happens
Package A Lambda function in the CICD account zips CodeBuild’s output and stores it in the shared artifacts bucket, under the commit ID
Approve I get an email and approve the deploy to Prod
Infrastructure The agent assumes a deploy role in the Prod account and updates the CloudFormation stack through a change set
Content The agent uploads only the files that changed, removes deleted ones and clears the CloudFront cache

Nothing in Prod is created by hand, and no laptop holds Prod credentials.

Serving the pages#

The pages sit in a private S3 bucket that only this CloudFront distribution can read, through Origin Access Control. A tiny CloudFront Function turns /posts/some-post/ into /posts/some-post/index.html before the cache lookup, because S3 behind OAC doesn’t serve folder index pages by itself.

The theme is the landing page’s: same fonts, same colour tokens, and the same Odisha-inspired theme every day across all four sites.

Counting readers without tracking them#

Each page load sends one request to a small Lambda function behind apps.tkmworks.co.in. It counts each visitor once a day, using a hash of the IP address and browser with a salt that changes daily. The IP address is never stored, and after two days DynamoDB’s TTL deletes the hashes and the salt. There are no cookies and no third-party scripts, and browsers that send Do Not Track or Global Privacy Control aren’t counted at all.

What it costs#

Close to nothing at this traffic. CloudFront’s free tier covers the requests, the certificate is free, and S3 storage for a few megabytes of HTML rounds to zero.

The next posts go deeper into the parts this one skimmed: the multi-account landing zone underneath, the build agent, and the release pipeline behind the apps page.