This site is a static Next.js export served from S3 through CloudFront. At personal-site traffic it sits inside the CloudFront free tier, ACM certificates are free, and the hosted zone is already paid for by another stack of mine. I expect it to cost under a dollar a month.
That price is a result of design choices, not stinginess. Each piece below is there because it removes a server, a secret or a bill. The whole thing is defined in Terraform.
A static export
The site has no runtime that needs a server. Next.js can emit plain HTML, CSS and JavaScript at build time, so that is what it does:
// next.config.ts
const config = {
output: "export",
images: { unoptimized: true },
};
export default config;Everything on the site, including both languages and the machine-readable llms.txt files, is rendered at build time from typed content modules. There is nothing to patch at runtime, no cold starts and no server to scale. Images are pre-built, so the image optimizer is off.
A private S3 bucket with OAC
The files live in an S3 bucket that is not public. Public access is blocked, objects are encrypted, versioning is on and old versions expire after 30 days. The only thing allowed to read the bucket is the CloudFront distribution, through origin access control (OAC).
statement {
principals { type = "Service" identifiers = ["cloudfront.amazonaws.com"] }
actions = ["s3:GetObject"]
resources = ["${bucket_arn}/*"]
condition {
test = "StringEquals"
variable = "AWS:SourceArn"
values = [distribution_arn]
}
}The bucket has no website endpoint and no public URL. If someone finds its name, they get nothing. All traffic goes through CloudFront, which is also where HTTP/3, security headers and the certificate live.
A CloudFront Function for clean URLs and www
S3 does not know that /es/ means /es/index.html, and a static export writes /articles as a file named articles.html. A small viewer-request CloudFront Function bridges that and also handles the www host.
function handler(event) {
var req = event.request;
var host = req.headers.host && req.headers.host.value;
if (host && host.indexOf("www.") === 0) {
return { statusCode: 301, statusDescription: "Moved Permanently",
headers: { location: { value: "https://" + host.slice(4) + req.uri } } };
}
if (req.uri.endsWith("/")) req.uri += "index.html";
else if (req.uri.lastIndexOf(".") < req.uri.lastIndexOf("/")) req.uri += ".html";
return req;
}Two behaviors in a few lines: www redirects to the bare domain with a 301, and extensionless paths map to the right file. CloudFront Functions run at the edge and cost very little, and there is no Lambda to maintain.
GitHub OIDC deploys with no stored keys
The deploy runs in GitHub Actions on every push to main. There is no AWS access key stored anywhere. Instead the workflow asks GitHub for a short-lived identity token and AWS exchanges it for temporary credentials.
permissions:
id-token: write
contents: read
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.AWS_DEPLOY_ROLE_ARN }}
aws-region: us-east-1
- run: scripts/deploy.shThe IAM role trusts only this repository's main branch, and its policy is scoped to this bucket and this distribution: list, put, delete and get on the bucket, and creating invalidations on the distribution. A leaked token cannot do anything else, and it expires on its own. After the sync, the workflow reads the live site back and checks the pages, the redirect and the text files, because exit 0 from an upload is not proof that the site works.
The HTML cache
The deploy script sets two cache policies, depending on the file:
| Files | Cache-Control | Why |
|---|---|---|
| Hashed assets in _next/static | public, max-age=31536000, immutable | The filename changes when the content does, so cache it forever. |
| Everything else, including HTML | public, max-age=0, s-maxage=300, must-revalidate | Browsers always revalidate; the edge may hold it for five minutes. |
That gives instant updates for visitors' browsers and a cheap edge. After each deploy the script also invalidates the distribution, so changes are visible immediately rather than after the five minutes. Text files for crawlers are uploaded with an explicit UTF-8 content type.
Analytics through a first-party /ingest proxy
The site uses PostHog for product analytics. Browsers and extensions that block third-party tracking often match known analytics hostnames. So the site sends events to its own /ingest path, and CloudFront forwards them.
- Two extra origins on the distribution: the analytics API and its static assets.
- Two behaviors: /ingest/static/* is cached, /ingest/* is not.
- A second CloudFront Function strips the /ingest prefix before the request goes on.
function handler(event) {
var req = event.request;
req.uri = req.uri.replace(/^\/ingest/, "") || "/";
return req;
}It is still analytics, so say so in your privacy notice. The point is not to hide anything; it is to stop a hostname-based blocklist from deciding what the site owner can measure.
CloudFront logs to Athena, for AI-crawler visibility
Client-side analytics only sees visitors who run JavaScript. It does not see crawlers, and it does not see people who block it. CloudFront access logs see every request.
Standard logging delivers hourly Parquet files to a separate private bucket. A Glue table with partition projection over the year, month, day and hour path means there is nothing to repair or register as new data arrives, and Athena queries it directly. Raw logs are kept for 25 months, so there are two full years to compare, and query results expire after 30 days.
The question I wanted answered is which AI crawlers fetch the site and what they read. A query grouping requests by user agent and path answers it, and it is also a check that the llms.txt files are being fetched at all.
SELECT cs_user_agent, cs_uri_stem, count(*) AS hits
FROM cloudfront_logs
WHERE year = 2026 AND month = 12
GROUP BY 1, 2
ORDER BY hits DESC
LIMIT 50;Athena bills per query by data scanned, so with a small site and Parquet the cost is negligible.
What it costs, and what it trades away
S3 and CloudFront at this traffic sit inside the free tier. ACM is free. The log bucket and Athena add storage and per-query charges that are tiny at this scale. I expect under a dollar a month in total.
The trade is that this stack only suits content that can be built ahead of time. A site with per-user pages or server-side writes needs more. For a personal site, a static export removes the server, the patching, the cold starts and most of the bill. If you want to publish machine-readable files for AI crawlers too, the llms.txt generator on this site is a starting point.