releaser: add CloudFront Function + KVS redirect path (lab)#25047
releaser: add CloudFront Function + KVS redirect path (lab)#25047dvdksn wants to merge 2 commits into
Conversation
Adds a second redirect path that uses a CloudFront Function backed by a CloudFront KeyValueStore (KVS) instead of Lambda@Edge: O(1) kvs.get(uri) per request instead of iterating the whole redirect map. Wired to the lab environment via two new env vars (DOCS_CLOUDFRONT_KVS_ARN, DOCS_CLOUDFRONT_FUNCTION_NAME) on the existing refs/heads/lab and refs/heads/main entries. The new deploy step is gated on both being non-empty, so prod stays Lambda@Edge-only until those vars are populated. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
✅ Deploy Preview for docsdocker ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
This PR adds a new CloudFront Function + KVS redirect path for the staging environment. All changed files are infrastructure and tooling (CI workflows, Go source, JavaScript CloudFront function, Dockerfile, bake config, env.json) — no markdown documentation pages were added, removed, or moved.
Checks passed:
- No vendored or generated data files touched
- No documentation pages removed or moved (no missing redirects)
- No user-facing documentation text with style violations
- No front matter or Hugo shortcode issues
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| @@ -5,9 +5,25 @@ go 1.26.0 | |||
| require ( | |||
| github.com/alecthomas/kong v1.4.0 | |||
| github.com/aws/aws-sdk-go v1.55.5 | |||
There was a problem hiding this comment.
For a follow-up, we should look at replacing the remaining v1 uses to v2 as well;
Lines 14 to 19 in d34246d
There was a problem hiding this comment.
Yes, I haven't looked at these much at all lately 🙈
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
This PR introduces a new CloudFront Function + KVS redirect system. The CI/workflow changes and Go infrastructure look well-structured. One confirmed logic bug in the CloudFront Function JS and two medium-severity concerns in the Go code need attention before this is wired to production.
Summary
Replaces the Lambda@Edge redirect handler with a CloudFront Function backed by a CloudFront KeyValueStore (KVS). The function does an O(1)
kvs.get(uri)lookup instead of iterating an inlined redirect map, at ~1/6 the per-request cost of Lambda@Edge.hack/releaser/cloudfront-function-redirects.js— KVS lookup → inline prefix loop → markdown content negotiation. ~3.5 KB, under the 10 KB limit.hack/releaser/aws_kvs.go— newaws cloudfront-function-updatesubcommand. Diffsredirects.jsonagainst current KVS contents, applies changes in batches of 50 viaUpdateKeys, thenUpdateFunction+PublishFunction(skipped if LIVE is unchanged).build.yml.env.json: two new fields (DOCS_CLOUDFRONT_KVS_ARN,DOCS_CLOUDFRONT_FUNCTION_NAME) per ref; the new deploy step is gated on both being non-empty.Lab vars are now populated. Prod stays on Lambda@Edge until those fields are filled in for
refs/heads/main.Related
Test plan
DRY_RUN=true releaser aws cloudfront-function-update ...— loads redirects, normalizes keys, renders the function templatebuildworkflow greenlabdocs-labs.docker.comreturn301with the rightLocation(exact-match, prefix-strip, prefix-no-strip)Accept: text/markdownreturns the.mdvariant