Skip to content

feat(infra): unify redirect stack; add www + move beta into doenet.org zone#3012

Open
cqnykamp wants to merge 5 commits into
Doenet:mainfrom
cqnykamp:infra/www-doenet-redirect
Open

feat(infra): unify redirect stack; add www + move beta into doenet.org zone#3012
cqnykamp wants to merge 5 commits into
Doenet:mainfrom
cqnykamp:infra/www-doenet-redirect

Conversation

@cqnykamp

@cqnykamp cqnykamp commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

What

  • Unifies the redirect stack into a single redirect.yml template that serves both the beta.doenet.org zone redirect and a new www.doenet.org single-host redirect.
  • Adds prod-doenet-www-redirect — 301s www.doenet.orgdoenet.org, so the site keeps a single canonical host (consistent with the beta redirect).
  • Moves the beta redirect off its own delegated hosted zone into the doenet.org parent zone. Both redirects now write into the doenet.org zone.

Template changes (redirect.yml)

  • New RedirectSubdomains param ("true"/"false", default true):
    • true — existing behavior: cover apex + *.<source>, carrying the subdomain label to the target (media.beta.doenet.orgmedia.doenet.org). Requires SourceHost to be a zone apex.
    • false — single host only: no wildcard SAN, no wildcard records. Safe to point at a zone that already serves other subdomains (that's why www uses it — its zone is doenet.org, which also holds media., api., etc.).
  • Params are now just RedirectName (beta/www) + the repo-standard PublicHostedZoneName / PublicHostedZoneId (as literals, matching the sibling us-east-1 prod-doenet-media-cert stack) + RedirectSubdomains. The source host is derived as <RedirectName>.<PublicHostedZoneName> and the redirect target is the apex PublicHostedZoneName, so neither needs its own param; RedirectName also forms the per-account-unique CloudFront function name + tags. (Assumes each redirect source is a subdomain of the target apex — true for beta/www; a cross-domain redirect would reintroduce an explicit source-host param.)
  • The one function body (query-string rebuild + host swap) now lives in a single place instead of being duplicated across two templates. Deleted redirect-host.yml.

prod-doenet-www-redirect is registered in prod.aws (STACKS, STACK_REGION=us-east-1, STACK_ORDER) and both params files now point SourceHostedZoneId at the doenet.org zone Z08210421B0UEN4PYID0X.

Deploy — order-sensitive, do NOT just aws-deploy.sh everything

1. www redirect (safe, new, no existing DNS): deploy prod-doenet-www-redirect. ACM validates against the doenet.org zone automatically. Pre-check: no existing www.doenet.org record collides.

2. Beta zone move (live DNS — needs care). The beta redirect currently answers via the delegated beta.doenet.org zone (Z0126382…). This PR makes CloudFormation manage the beta records in the doenet.org parent zone instead. Because DNS delegation is binary, moving records between zones is not gapless by default — while the beta.doenet.org NS delegation still exists in doenet.org, parent-zone records for beta.* are shadowed; once the beta stack update deletes the child-zone records, beta.doenet.org stops resolving until the delegation is removed.

Recommended sequence, in a short planned window (only legacy redirect traffic is affected):

  1. Deploy the repointed prod-doenet-redirect stack (writes beta apex+wildcard records + cert-validation CNAME into the doenet.org zone). The beta ACM cert keeps the same DomainName/SANs, so it is not replaced.
  2. Remove the beta.doenet.org NS delegation record from the doenet.org zone → resolution flips to the parent-zone records (same CloudFront target).
  3. Verify curl -sI https://beta.doenet.org/foo and a *.beta.doenet.org host both still 301 to doenet.org.
  4. Delete the now-empty beta.doenet.org hosted zone (Z0126382…).

Verify in the Route 53 console before executing step 1/2: confirm whether Route 53 permits creating the beta.* alias records in the parent zone while the NS delegation still exists (it may require removing the delegation first). If it does, swap steps 1 and 2 and accept a brief TTL-bounded blip. I couldn't check this from the sandbox (no AWS access).

Notes

  • These templates change rarely and are now shared by two prod stacks, so a template bug reaches both on their next deploy — the tradeoff we accepted for de-duplicating the function logic.

🤖 Generated with Claude Code

… zone

Generalize redirect.yml into one template that serves both the beta.doenet.org
zone redirect and the www.doenet.org single-host redirect, and add the www
stack (prod-doenet-www-redirect) that 301s www.doenet.org -> doenet.org so the
site keeps a single canonical host.

Template changes (redirect.yml):
- Add RedirectSubdomains ("true"/"false", default true). true keeps the existing
  apex + *.<source> behavior with subdomain-label carry; false emits just the
  single host (no wildcard SAN, no wildcard records) so it is safe to point at a
  zone that already serves other subdomains.
- Rename SourceHostedZoneName -> SourceHost and add RedirectName, a dot-free
  label used for the per-account-unique CloudFront function name and tags.
- The one function body (query-string rebuild + host swap) now lives in a single
  place instead of being duplicated.

Move the beta redirect off its own delegated hosted zone into the doenet.org
parent zone (SourceHostedZoneId -> Z08210421B0UEN4PYID0X); beta.doenet.org is a
subdomain of doenet.org and only needs a separate zone if delegated, which a
dumb redirect no longer warrants. Both redirects now write into the doenet.org
zone. Deleting the now-redundant beta.doenet.org hosted zone + its NS delegation
is a follow-up (see PR notes) since it is an order-sensitive live DNS change.

Deleted redirect-host.yml (folded into redirect.yml).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cqnykamp cqnykamp changed the title feat(infra): redirect www.doenet.org -> doenet.org feat(infra): unify redirect stack; add www + move beta into doenet.org zone Jul 18, 2026
@cqnykamp
cqnykamp force-pushed the infra/www-doenet-redirect branch from 5497355 to 426b15e Compare July 18, 2026 16:40
cqnykamp and others added 2 commits July 18, 2026 11:42
… zone

Generalize redirect.yml into one template that serves both the beta.doenet.org
zone redirect and the www.doenet.org single-host redirect, and add the www
stack (prod-doenet-www-redirect) that 301s www.doenet.org -> doenet.org so the
site keeps a single canonical host.

Template changes (redirect.yml):
- Add RedirectSubdomains ("true"/"false", default true). true keeps the existing
  apex + *.<source> behavior with subdomain-label carry; false emits just the
  single host (no wildcard SAN, no wildcard records) so it is safe to point at a
  zone that already serves other subdomains.
- Replace the source/target params with a single RedirectName label (e.g.
  "beta", "www") plus the repo-standard PublicHostedZoneName / PublicHostedZoneId
  (matching the sibling us-east-1 media-cert stack, which also passes them as
  literals). The source host is derived as <RedirectName>.<PublicHostedZoneName>
  and the redirect target is the apex PublicHostedZoneName, so neither needs its
  own param; RedirectName also forms the per-account-unique CloudFront function
  name and tags.
- The one function body (query-string rebuild + host swap) now lives in a single
  place instead of being duplicated.

Move the beta redirect off its own delegated hosted zone into the doenet.org
parent zone (SourceHostedZoneId -> Z08210421B0UEN4PYID0X); beta.doenet.org is a
subdomain of doenet.org and only needs a separate zone if delegated, which a
dumb redirect no longer warrants. Both redirects now write into the doenet.org
zone. Deleting the now-redundant beta.doenet.org hosted zone + its NS delegation
is a follow-up (see PR notes) since it is an order-sensitive live DNS change.

Deleted redirect-host.yml (folded into redirect.yml).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dqnykamp

Copy link
Copy Markdown
Member

@cqnykamp, in PR #3010, I added and changed the names of the component-tests. I modified the branch protection rules to expect the new set. We'll either need to merge in #3010 first or override the branch protection rules until it is merged.

cqnykamp and others added 2 commits July 19, 2026 00:03
Rename the redirect param files to the <env>-doenet-redirect-<name> stack
naming convention and register the beta/www redirect stacks on dev3 for
testing (dev3.doenet.org zone Z0066937J8QHRAL9H84P).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts:
#	infra/cloudformation/prod-doenet-redirect.params
#	infra/cloudformation/redirect.yml
#	infra/prod.aws
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants