Skip to content

DNS and certificates

2 min read · main part only; folded sections are optional

After this you can answer: How does a browser find MiniTickets, and where does the HTTPS certificate come from?

flowchart TB
B[Browser] -->|"1. look up name"| CF["Cloudflare DNS"]
CF -->|"CNAME"| ALBDNS["ALB DNS name"]
B -->|"2. HTTPS"| ALB["ALB :443"]
ACM["ACM certificate"] --> ALB
ACM -.->|"checks validation CNAME"| CF
  1. Look-up. The browser asks DNS for minitickets.theversehub.in. Cloudflare answers with a CNAME to the ALB’s AWS name, which resolves to its current IPs.
  2. Validation. ACM asks us to add a special CNAME record. When ACM sees it, it knows we control the domain and issues the certificate.
  3. HTTPS. The browser connects to the ALB on 443. The ALB shows the certificate; the browser checks it matches the name and is signed by a trusted authority.
  4. Renewal. ACM renews the certificate by itself, as long as the validation record stays in DNS.

The certificate covers exactly one name, no wildcard (infra/src/certificate.ts → createCertificate). It is always on when domainName is set, so it is already issued on deploy day. Before the HTTPS listener is created, Pulumi waits up to 10 minutes for status ISSUED.

Cloudflare holds four kinds of records for us: the app CNAME, the ACM validation CNAME and three SES DKIM CNAMEs for signed email. The Cloudflare proxy must be off (DNS only) for all of them.

HTTPS also matters to log-in: the session cookie is Secure, so the browser sends it only over HTTPS.

From → toWhat happensWhat allows it
Browser → Public DNSonly when cdnEnabled = falselooks up minitickets.theversehub.in and gets the ALB's DNS name
  • dns CNAME minitickets.theversehub.in → the ALB's DNS name (stack output appDnsRecord), added by hand at Cloudflare, proxy offappDnsRecord
Public DNS → ACM certificateACM finds its validation record and issues (and later renews) the certificate
  • dns validation CNAME _<random>.minitickets.theversehub.in (stack output certificateValidationRecord), kept forevercreateCertificate
SES email identities → Public DNSreceiving mail servers check the DKIM signature against our DNS
  • dns 3 CNAMEs <token>._domainkey.minitickets.theversehub.in → <token>.dkim.amazonses.com (stack output sesDkimRecords)createEmail
See the DNS on the map →

Certificate Manager → Certificates → minitickets.theversehub.in → Status, and Domains (the CNAME name and value).

SymptomCauseWhere to look
The domain shows a DNS error after a redeployThe CNAME still points at a deleted ALBCloudflare record vs albDnsName output
The deploy waits 10 minutes, then failsValidation CNAME missing, status PENDING_VALIDATIONACM → the certificate
Certificate or DKIM never validatesThe record is proxied in CloudflareProxy status must be DNS only
Why a CNAME and not the ALB's IP address?

An ALB’s IPs change as AWS scales it. Its DNS name stays the same for the life of the ALB, so pointing a CNAME at it is the stable choice.

What would Route 53 change?

An alias record could point the bare domain at the ALB, and Pulumi could create every record itself. The manual step, and the stale-CNAME risk after a redeploy, would disappear.

Why must the certificate be in us-east-1?

An ALB can only use a certificate from its own region, and ours is in us-east-1. CloudFront also requires us-east-1 for its certificates.

Advanced: What switching entry off and on does

Switching entryEnabled off deletes the ALB. Switching it on creates a new one with a new DNS name. The certificate survives (it is not behind the switch), but the app CNAME at Cloudflare must be updated to the new name: pulumi stack output appDnsRecord prints it.

Answer these without scrolling up. If one feels hard, reread that section.

  1. What does the app’s DNS record point at, and why not an IP?
  2. How does ACM know we own the domain?
  3. Which records does Cloudflare hold for MiniTickets?
  4. What breaks after the ALB is recreated?
  5. Why does log-in need HTTPS?

Redraw it from memory: browser → Cloudflare (CNAME) → ALB, and ACM checking its validation record

Try this: run dig +short CNAME minitickets.theversehub.in and compare it with the ALB's DNS name in the console

Read this book online: https://book.theversehub.in/