Repository navigation
docs(hosting,pipeline): props and errors tables, front doors first, custom door guide in its own file - #1636
Conversation
🦋 Changeset detectedLatest commit: f74f277 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
f74f277 to
8e92646
Compare
8e92646 to
12190dd
Compare
osama-rizk
left a comment
There was a problem hiding this comment.
This PR moves the custom-door guide into its own file, adds props and errors tables to the hosting README, and documents every pipeline option. The tables are accurate and the corrections are real. I'm leaving comments, not blocking: a fact-by-fact comparison against main turned up a few dropped limitations and one security guarantee that should come back before merge, plus one row that is wrong for HostingConstruct users.
What's good
- The
StreamingServerNeedsStreamingDoorErrorcorrection foralb/stackedis right (hosting_construct.ts:3002-3015), and the single streaming table replaces three paragraphs that contradicted each other. - I checked every error name in
## Errorsagainst its throw site. All 29 exist, andname === codeholds (hosting_error.ts:17-24). The conditions I checked match the source: the skew range,'none'with a server, geo type, the wiring check and the SSR cache errors. - The
HostingConstructProps, adapter,serverOrigin, store and SSR-cache defaults match the source. The pipeline tables also match on every default and throw site. CUSTOM-FRONT-DOOR.mdships infiles[]. The wiring check now names the real error (custom_door.ts:164) and the real warning ids. The HTTPS stacked example type-checks against aws-cdk-lib 2 undertsc --strict, with only the@aws-blocks/hosting/constructsimport stubbed.- Every anchor resolves, and nothing else in the repo links into a hosting README anchor that the restructure renamed.
What needs work: 3 should-fix · 8 minor · 3 nit, all non-blocking; details are inline.
Open questions
- Was dropping the Web Functions internals (the code bucket, content-derived revisions, the
lambda:InvokeWebFunctionEndpointcustom resource) meant to remove them from the docs entirely? Or should they go to apackages/hosting/DESIGN.md, the per-block convention, since this README was where they were recorded? - For the pipeline question in the description: since the AWS Blocks templates point
cdk.jsonataws-blocks/index.cdk.ts, I'd recommendnpx cdk synth --app …insynth.commands. That keeps onecdk.jsonfor local deploys and the pipeline. Whichever you choose, the first example should importPipelinefrom@aws-blocks/core/cdk(inline).
Cross-cutting
- The secrets limits (region, account-global prefix,
stagenot a security boundary) moved from a callout near the top to a plain list at the end, after monitoring. They're the most common deploy-time surprises. Consider keeping a one-line pointer to them from the Quick start or the props table row forsecretStore/configStore. - The changeset is about 30 lines of public changelog for a docs patch, and it repeats the HTTP API claim flagged inline. A shorter list of the corrections would read better in
CHANGELOG.md. - Naming follows the "AWS Blocks" convention throughout. The repo moved to
aws/cdk-blocks, but the product name and thepackage.jsonURLs on main are unchanged, so nothing here needs renaming.
12190dd to
4df74fe
Compare
osama-rizk
left a comment
There was a problem hiding this comment.
Since the last review: 14 resolved · 1 new · 0 still open
Approving. Every comment from the last review is fixed in 4df74fe, and I checked each fix against the source rather than the commit message. One new nit is inline as a follow-up.
The branch history was rewritten: the previously reviewed head 12190dd is no longer an ancestor, because the PR was rebased onto a newer main. So I compared the PR's own diff against its new merge base (f13a11c), not head to head. Apart from 4df74fe, the rebased commits are unchanged, except that the hosting README now keeps main's ## License section and its third-party notices paragraph.
Resolved (verified against source)
- HTTP API row and bullets: these are now scoped to core
Hosting, and thewithBuildProfilerecipe is given forHostingConstruct.withBuildProfileis exported from@aws-blocks/hosting/adapters(adapters/index.ts:23), and core passesserverInvoke: 'http-api'for that door (core/src/hosting.ts:1269-1271). - Open-redirect guarantee and redirect routing: restored. They match
asset_proxy.test.ts:379-388(/old//evil.example→/evil.example). - Untagged builds from pre-tagging releases: restored in the retention section.
- Web Function internals: restored. The versioned bucket and
web-function/<fn>/code.zipkey, the content-derived revision ID, theHOST/PORTentry shim and thelambda:InvokeWebFunctionEndpointcustom resource all matchweb_function_construct.ts. - Cache-key caps: now stated as quota-relative (10 minus 2 or 5 reserved, raisable through
quotas.*). This matchescdn_construct.ts:813-836andquota_budget.ts:117-118. - Schema JSON-parse: now tied to the synth flag, not to typegen (
secret-resolve.ts:351,secret-runtime.ts:67-70). - Codec compatibility boundary and the version rationale: restored.
- Errors table: the five missing errors are added. Each condition matches its throw site, including the Web Function option ranges (
web_function_construct.ts:570-592) and the behavior cap (cdn_construct.ts:1359). - ALB per-rule limits (
MAX_CONDITION_VALUES = 5,MAX_RULE_WILDCARDS = 6) and the single API-scoped invoke permission: restored. acceptLegacyVerifyHeader: the derivable-value warning is added.- Deprecated aliases: the same-template promise is back.
set: now reads "no overwrite confirmation".- Pipeline quick start: it imports
Pipelinefrom@aws-blocks/core/cdk(astest-apps/pipelinedoes) and uses an explicitnpx cdk synth --app …, socdk.jsonstays onindex.cdk.ts. bakeTime: the row now says whole minutes, which matchestoMinutes().- Body items: the changeset is shortened, and the
secretStore/configStorerow now links to the region, prefix and stage limits.
The HTTPS stacked example in CUSTOM-FRONT-DOOR.md is unchanged, and it still type-checks under tsc --strict against aws-cdk-lib 2.
What needs work: 1 nit, non-blocking. Details are inline.
Open questions: none.
Cross-cutting: the red Local Build and Checks job is not caused by this PR. check:headers flags 14 Dart files under native/dart/ that came from main (#1575), and Build and Test / Build, Unit Tests, E2E Local fail only because they depend on that job. This PR touches no source files.
…R.md The section is a guide for writing a door with defineFrontDoor, not for apps that pick a built-in door. It moves verbatim into CUSTOM-FRONT-DOOR.md, which is added to the package's files. The README keeps the heading, a summary, a link from the front-door table, and what AWS Blocks checks and enforces for such a door.
…ors before secrets and config The README said a Next.js server behind the `alb` and `stacked` doors was "the exception" and should be served through CloudFront; it now says synth fails there with `StreamingServerNeedsStreamingDoorError`, and one table gives streaming and buffered behavior per door and framework. Other corrections: `getSecret` throws `no secret reference found`, `HostingConstruct` is exported from `@aws-blocks/hosting/constructs`, the codec example imports the names it calls, and `allowPlainHttp` is listed among the door options. The README had no quick start, no list of `HostingConstructProps` and no list of errors. It now has a `## Quick start` with adapter, entry-point and props tables, option tables for `secretStore` / `configStore`, `serverOrigin` and the SSR cache options, and an `## Errors` table of 29 `HostingError` names with the condition that throws each. Sections are ordered quick start, front doors, Next.js, SSR compute, build retention, access logging, SSR caching, custom domains, monitoring, secrets and config, errors. The `allowPlainHttp` rule and the streaming rule are each stated in one place, and the other sections link to it. `## Overview`, `## Main exports`, `## Architecture`, `## Development`, `## License`, a pull request link, a decision reference and the description of how a Web Function is packaged are removed.
…s HTTPS in the stacked example The guide said the wiring check fails synth "with `ServeStaticAsset`" or "with `ProxySameOriginApi`"; it throws `UnsupportedFrontDoorError`, and those are the rule names in its message. The example of a door that stacks CloudFront over its own ALB sent the origin secret over plain HTTP to port 80; it now uses an HTTPS listener on 443 and an `HTTPS_ONLY` origin, and says why. The `cf.*` helpers are in a table of eight rows, the three warnings of the wiring check are listed with their ids, and the shared exports are a list. The two limits of the first example door (single-page-app deep links, request bodies to the server) are stated before the code.
…very prop The README said only to use `Pipeline.create()` for async stage factories; `new Pipeline()` also throws for an `App` scope, for `appFile` and for a `config()` marker as `connectionArn`, and a table now compares the two forms. The props were not documented. `## Options` now has tables for `PipelineProps`, `source`, `branches[]`, `stages[]` and `synth` with types and defaults, and states the store prefixes that `Pipeline` from `@aws-blocks/core` defaults to. The first example is a complete `aws-blocks/pipeline.cdk.ts` that calls `await Pipeline.create(app, ...)` with the default `appFile` and a per-stage `environment`; the `stageFactory` form is the second example. The one-time OAuth handshake of the CodeConnections connection is stated, and "Opt out of the Node.js 22 default" is folded into the `null` case of `synth.partialBuildSpec`.
4df74fe to
d4ea141
Compare
Keep the origin header and certificate hostname when switching to a VPC origin. Apply redirect and header rules to each behavior and require an ACL when the custom door enables WAF. Distinguish cache quotas from hard limits. Show how to avoid reusing a backend module between pipeline stages, and clarify CodeBuild log masking and KMS permissions.
Problem
packages/hosting/README.mdwas 1,669 lines (12,969 words).## Secrets & config, more than 200 lines, came before the choice of front door, and about 235 lines for authors of a custom door sat inside## Front doors.HostingConstructPropsand no list of errors. Many sentences said "fails synth" or "throws" without the error name.albandstackeddoors called it "the exception" and told the reader to "serve it there through CloudFront"; synth fails there. The custom-door wiring check was said to fail "withServeStaticAsset", which is a rule name in the message ofUnsupportedFrontDoorError. The stacked custom-door example sent the origin secret over plain HTTP.allowPlainHttprule and the streaming/buffered rule were each restated in several sections.packages/pipeline/README.md(124 lines) documented none of its props and said ofPipeline.create()only that async stage factories need it.Issue #, if available:
Changes
This pull request has four commits. The first,
74bea9719, moves "Bring your own front door" verbatim intopackages/hosting/CUSTOM-FRONT-DOOR.mdand adds that file tofilesinpackages/hosting/package.json. The README keeps the heading, a summary, a link from the front-door table, and what AWS Blocks checks and enforces for such a door. The other three commits are on top of it.packages/hosting/README.mdCorrections:
albandstackedfails synth withStreamingServerNeedsStreamingDoorError; behind the HTTP API the adapter builds it buffered (packages/hosting/src/constructs/hosting_construct.ts:3002-3015,packages/hosting/src/adapters/shared/build_profile.ts:5-11).getSecretthrowsno secret reference found; the README gave only thegetConfigmessage (packages/hosting/src/secret-runtime.ts:141).HostingConstructis exported from@aws-blocks/hosting/constructs(packages/hosting/src/constructs/index.ts:18), not@aws-blocks/hosting.packages/hosting/src/index.ts:19-48); it imported four it did not use and omittedconfig,secretandisSecret.UnsupportedFrontDoorErrorandInvalidFrontDoorOptionError(packages/hosting/src/constructs/front_door_options.ts:620,651,669).Added, derived from the source:
## Quick start: a runnable adapter call, the adapter table (src/adapters/{nextjs,nitro,astro,sveltekit,spa}.ts), the entry-point table (package.jsonexports) and theHostingConstructPropstable (src/constructs/hosting_construct.ts:170-607).## Errors: 29HostingErrornames, each condition taken from its throw site insrc/constructs/*.tsandpackages/core/src/hosting.ts:2037,2239.secretStore/configStore(src/secret-resolve.ts:50-68),serverOrigin(src/constructs/front_door_options.ts:100-137) and the SSR cache options (src/constructs/cdn_construct.ts:810-963).### Streaming and buffered servers, a table by door and framework, the one statement of that rule.Reordered: quick start and props, front doors, Next.js, SSR compute, build retention, access logging, SSR caching, custom domains, monitoring, secrets and config, errors.
allowPlainHttpis stated once, under "Running a plain-HTTP door in production"; the other sections link to it.Removed:
## Overview,## Main exports,## Architecture(the introduction and quick start cover them),## Development,## License, the link to #968, the referenceD-016, and how a Web Function is packaged (code bucket key, revision ids, entry shim).packages/hosting/CUSTOM-FRONT-DOOR.mdUnsupportedFrontDoorError, whose message lists the unmet rules (packages/hosting/src/constructs/custom_door.ts:126,134,164).HTTPS_ONLYorigin at arouterDomainNamethe reader supplies. The built-in stacked door rejects the plain-HTTP shape in production (packages/hosting/src/constructs/cloudfront_edge_door.ts:133-159).cf.*helpers (src/constructs/cf_helpers.ts:195-310), withInvalidPropsErrorforcf.redirects/cf.headers(cf_helpers.ts:240,256).packages/pipeline/README.mdnew Pipeline()throws for anAppscope, forappFile, for anasyncstageFactoryand for a markerconnectionArn(packages/pipeline/src/pipeline-construct.ts:172-196,364-370); a table compares it withPipeline.create().## Options: tables forPipelineProps,source,branches[],stages[]andsynth(src/types.ts,src/pipeline-construct.ts), plus the prefixesPipelinefrom@aws-blocks/coredefaults to (packages/core/src/pipeline/index.ts:33-41).aws-blocks/pipeline.cdk.tswithawait Pipeline.create(app, ...).packages/hosting/README.mdpackages/hosting/CUSTOM-FRONT-DOOR.md(new)packages/pipeline/README.mdThe pipeline README grows because its props were not documented before. The hosting text as a whole (README plus the new file) goes from 1,669 to 1,574 lines.
Look hardest at:
## Errors,HostingConstructProps, the store,serverOriginand SSR cache options, and the pipeline options tables. Each row is a claim about the source.CUSTOM-FRONT-DOOR.md. It is standard CDK (certificatesonaddListener,HTTPS_ONLY) and was not synthesized.packages/blocks/src/test-support/doc-snippets.ts:19-23).Not changed on purpose:
acceptLegacyVerifyHeaderand the deprecated top-level props stay in the README, shortened: an app that still uses them needs the error names and the steps.Open questions:
cdk.json'sappto the pipeline file, astest-apps/pipeline/cdk.jsondoes. The app templates point ataws-blocks/index.cdk.ts;npx cdk synth --app …insynth.commandswould keep both entry points usable. Which should the README recommend?acceptLegacyVerifyHeaderupgrade steps, which are release-specific, move to a migration file?Related pull requests: This supersedes the hosting part of #1496: the move of "Bring your own front door" is taken over unchanged as
74bea9719. Open pull requests that touchpackages/hosting/README.md:CUSTOM-FRONT-DOOR.mdWhichever merges second rebases.
Part of a set of README revisions: #1635 (core), #1637 (bb-agent and bb-knowledge-base), #1638 (bb-auth and auth-common), #1639 (the storage blocks), #1640 (compute, jobs, realtime, email and observability), #1641 (the guide, the scaffolder and its templates), #1642 (the native SDKs), #1643 (contributor docs). Each merges on its own.
Validation
Run on this branch alone at
12190ddb7, onmain8940cfd2f, with Node 22. All pass:npm run buildpackages/blocks(readme-links,docs-pointers,doc-snippets,imports-reference)packages/blockssandbox-dir-coverage(no tracked file names the old directory.blocks-sandbox)packages/corereadme-policies(the IAM policy JSON)packages/bb-authreadme-recipes,first-admin,multi-block-snippets,users-cli,gate-diagnosticspackages/auth-commonui.react-typespackages/bb-kv-storereadme.generated(every README snippet compiled) andlegacy/runtimepackages/create-blocks-appnpm testnpm run sync-docs:checknpm run check:importschangeset-guard.ts validate-structurechangeset-guard.ts verify-coveragechangeset-guard.ts verify-umbrellachangeset-guard.ts block-major#anchorin the changed files, and every link into them from another Markdown file, resolves (checked with a script)Run once on all the README branches of this set combined, as they were on an earlier
maincommit (e1e484465), and not run again after the rebases:packages/coreunit suite,packages/blocksunit suite,packages/bb-kv-storeunit suite,packages/bb-authunit suite,packages/auth-commonunit suite,npm run lint,npm run lint:depsandnpm run check:api. All passed.Not run locally: the full
npm testacross all workspaces,npm run test:e2e:localand the sandbox e2e suites. CI runs them.Files other than Markdown in this pull request:
packages/hosting/package.json.No test was added: the tests listed above already read these READMEs, and the remaining statements are checked against the source by review.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.