Repository navigation
feat(runtime): allow public BYO access-point mounts - #2936
ksayee-aws wants to merge 1 commit into
Conversation
| } | ||
| const hasByo = efsCount > 0 || s3Count > 0; | ||
| if (hasByo && data.networkMode !== "VPC") { | ||
| const hasPublicByo = hasByo && data.networkMode === "PUBLIC" && data.platformVersion === "V2"; |
There was a problem hiding this comment.
This rejects two configs the service accepts, and demands a flag that changes nothing.
Probed against the real schema:
ACCEPT PUBLIC + V2
REJECT PUBLIC + no platformVersion <-- false rejection
REJECT no networkMode + V2 <-- false rejection
ACCEPT VPC + no platformVersion
networkMode unset means PUBLIC. It's the service default, gateway.ts:193 defaults it, and line 444 of this same superRefine already uses !== "VPC". It's also a no-op in the template: the L3 keys off networkConfig, so networkMode: "PUBLIC" and unset synthesize byte-identical CloudFormation. Reproduced on this branch:
$ agentcore add runtime --name probe --language python --platform-version V2 \
--filesystem-configurations '[{"efsAccessPoint":{...}}]'
Error: x efsAccessPoint and s3FilesAccessPoint filesystem mounts require
networkMode: VPC, or networkMode: PUBLIC with platformVersion: V2
The user is on PUBLIC and did pass V2. The error tells them to do what they just did.
platformVersion unset is not the same as "not V2." Line 412: "Removing this keeps a deployed runtime on its current version." So an already-V2 runtime with the field removed is effectively V2, and the service — which checks the effective version — accepts the mount. This rejects it.
(The published L3 schema doc says unset means V1, contradicting line 412. Which is right decides whether this clause is correct — worth settling.)
Fix is one line and strictly closer to the service:
if (hasByo && data.networkMode !== "VPC" && data.platformVersion === "V1") {The service already fails closed with a clear 400 on a version mismatch, so catching only an explicit V1 is the better trade. As written, hasPublicByo's inner hasByo && is also dead — line 560 already requires it.
Worth noting the inconsistency this creates: s3BucketMount deliberately leaves the V2 rule to the service (runtime.test.ts:382), while this adds a client rule stricter than it — same superRefine, same service rule, opposite policies.
There was a problem hiding this comment.
Addressed in d61d330. I verified VolumeConfigurationValidator.validateByoStorageNetworkMode: omitted network mode is neither VPC nor PUBLIC at create, and an unresolved platform version runs as V1, so both reject. I retained the explicit PUBLIC+V2 rule, removed the redundant inner hasByo, and split the schema matrix into focused message/path assertions.
| flag( | ||
| "filesystem-configurations", | ||
| "filesystem mount configurations (JSON); an s3BucketMount needs --platform-version V2", | ||
| "filesystem mount configurations (JSON); public EFS and S3 Files access-point mounts require --network-mode PUBLIC and --platform-version V2 (Preview, commercial Regions only)", |
There was a problem hiding this comment.
This drops the only user-facing warning for a live rule. The old string carried an s3BucketMount needs --platform-version V2; nothing else in the toolchain does. The CLI deliberately doesn't enforce it — runtime.test.ts:382 is it("leaves the platformVersion V2 rule to the service") — and neither does the L3. Probed: s3BucketMount + V1 parses clean. The only surviving copy is generated command.md, which the release workflow overwrites.
It also misleads about VPC. "access-point mounts require --network-mode PUBLIC and --platform-version V2" reads as the rule for access-point mounts generally. VPC needs neither flag and is the GA route, so a reader with only --help would think they must opt into a Preview to mount EFS at all. The schema message on runtime.ts:564 names both routes; this should match.
filesystem mount configurations (JSON); an s3BucketMount needs --platform-version V2;
EFS and S3 Files access-point mounts need --network-mode VPC, or --network-mode PUBLIC
with --platform-version V2 (Preview, commercial Regions only)
Minor: at 174 chars this is now the longest flag help in the file (next is --language at 149), and it skips the file's terse convention for version constraints — compare --hooks-configuration's "(JSON, V2 only)".
There was a problem hiding this comment.
Addressed the VPC wording in d61d330: help now says EFS/S3 Files access-point mounts use VPC, or PUBLIC+V2 Preview. Per the requested feature scope, I left the unrelated s3BucketMount/Mountpoint warning unchanged.
| "toolRuntimes", | ||
| ]); | ||
|
|
||
| export const PUBLIC_BYO_MOUNTS_CN_MESSAGE = |
There was a problem hiding this comment.
Nit — missing the doc comment every neighbour in this block has. BMA_CN_MESSAGE (:212), HARNESS_CN_MESSAGE (:221), MEMORY_STRIPPED_CN_MESSAGE (:323) and cnConnectorTargetMessage (:290) each carry a /** Shown when ... */ explaining when it fires and why the restriction exists. These two have none — and hasPublicByoAccessPointMount is the item here most in need of one, since it deliberately restates part of a rule that lives in projectSchemas/runtime.ts (see below).
Three smaller things while you're here:
- The helper splits the China-constants block, landing between
CN_SUPPORTED_SPEC_COLLECTIONS(:274) andcnConnectorTargetMessage(:298), which is otherwise an unbroken run of message constants. - Two names for one concept — the constant says
PUBLIC_BYO_MOUNTS, the function saysPublicByoAccessPointMount. - The message omits GovCloud ("deploy to a supported commercial region") where
BMA_CN_MESSAGE:213says "commercial or GovCloud". Consistent with the new help text, so probably deliberate — just confirming the Preview really excludes GovCloud. AlsoBMA_CN_MESSAGEuses lowercase "region"; this PR introduces "commercial region" here, "commercial Regions" in the help, and lowercase "preview" indocs/china-regions.md.
On the helper's design: it checks networkMode === "PUBLIC" and not platformVersion === "V2", relying on the schema invariant that PUBLIC + BYO implies V2. That restraint is correct, and I'd rather have it than a redundant re-check. But the reliance is undocumented and untested — see my comment on manager.test.ts.
There was a problem hiding this comment.
Fixed in d61d330: moved the helper beside the China add predicate, added the design JSDoc, renamed the constant to match the helper concept, and aligned commercial-region/Preview wording. The helper documents its reliance on the PUBLIC+V2 schema invariant.
| if (input.resourceType === "harness") { | ||
| throw new RegionUnsupportedFeatureError(HARNESS_CN_MESSAGE); | ||
| } | ||
| if (input.resourceType === "runtime" && hasPublicByoAccessPointMount(input.resourceConfig)) { |
There was a problem hiding this comment.
The overall placement is right, and I checked it properly rather than assuming.
Two guards rather than one is the correct call — a user can add the runtime before adding a China target, so an add-time check alone would leak.
I also traced every path a runtime spec can enter a project: add runtime (both flags and the TUI wizard, which funnel through the same addResource), add runtime --agent-id (Bedrock Agent import), export harness --arn, create/init templates, a hand-edited agentcore.json, a spec written by an older CLI, and migrate. The deploy guard covers all of them. I found no route by which a PUBLIC access-point mount reaches a China deploy.
One low-severity gap worth knowing about: export harness --arn bypasses addResource entirely and has no region guard of any kind, while templates/export.ts:274 copies networkMode and never sets platformVersion. Exporting a deployed PUBLIC harness that carries mounts therefore yields a spec rejected later with the generic mount message, giving no hint that the exporter dropped platformVersion. It's the one path where the config is machine-generated rather than user-typed.
There was a problem hiding this comment.
Fixed in d61d330. Exported PUBLIC access-point harness configurations now receive platformVersion V2, and a contract test proves the emitted runtime validates. VPC exports remain unchanged.
| } | ||
| } | ||
|
|
||
| test("deploy to a China target rejects public EFS or S3 Files mounts", async () => { |
There was a problem hiding this comment.
Two mutations survive these tests. I ran both against the full suite:
| Mutation | Result |
|---|---|
Drop runtime.networkMode === "PUBLIC" from the guard (manager.tsx:284) |
5,264/5,264 pass |
Drop || "s3FilesAccessPoint" in mount from the guard (manager.tsx:286) |
5,264/5,264 pass |
Replace the interpolated message here with the bare constant (manager.tsx:1658-1662) |
187/187 pass |
The first one matters most. Without the PUBLIC guard, the China check blocks all EFS and S3 Files mounts in China — including the VPC-mode mounts that are supposed to keep working — and nothing notices. There's no test pinning "a VPC-mode EFS mount still adds to, and deploys to, a China target." That's also the test that documents why the helper can safely skip the platformVersion check.
Compare the BMA sibling, which has three tests including an explicit negative at :1342 ("ignores BMA template markers without the explicit field").
The second means the hand-written half of the deploy message is untested. Line 1296 asserts only toContain(PUBLIC_BYO_MOUNTS_CN_MESSAGE); the BMA sibling at :1324 also asserts toContain("runtime 'environment_python_bma'"), pinning the interpolation. One line, right there, not copied.
The S3 Files one is the starkest. Both new tests (:991 and :1273) use only efsAccessPoint. The message, the helper name, the test names and docs/china-regions.md all say "EFS or S3 Files" — and the S3 Files half of the gate is asserted nowhere. Half the feature's China block has no regression guard.
Suggested additions:
- Parameterise both tests over
efsAccessPointands3FilesAccessPoint. - A negative test: VPC-mode EFS mount against a China target succeeds at both
addanddeploy. expect(String(error)).toContain("runtime 'environment_python'")alongside the existing assertion.
What these two tests already get right, and better than the schema test in the same PR: they assert the error type, the message, and the absence of side effects (checkedTools empty here, deployCalls empty at :1297). That's the right shape.
There was a problem hiding this comment.
Fixed in d61d330. Add and deploy coverage now parameterizes EFS and S3 Files, asserts the interpolated runtime name, and includes explicit VPC-mode EFS regressions proving both China gates allow the VPC path.
| ).toBe(false); | ||
| }); | ||
| it("enforces filesystem counts, VPC dependency, and unique mount paths", () => { | ||
| it("enforces filesystem counts, network mode, platform version, and unique mount paths", () => { |
There was a problem hiding this comment.
This test now carries four rules and seven bare .success assertions, and the first failure hides the rest.
Under a mutation that breaks one case, the suite reported 129 expect() calls against a baseline of 133 — four later assertions in this test never ran. The title is itself the signal: a comma list of four concerns means a failure gives you a line number and nothing else.
Two concrete consequences:
- The
PUBLIC+V1case (:272-279) asserts onlyfalse. It would still pass if the rejection came from an unrelated rule — a tightened ARN regex, a mount-path change — so it does not actually pin the platform-version rule it's named for. - The first case (:266-271) —
codeZipAgent+ mounts withnetworkModeabsent — silently changes meaning under the!== "VPC"fix I suggested onruntime.ts:559. It would quietly start testing something else rather than failing loudly. Apath/message assertion would force that to surface.
This isn't a pre-existing-style argument, because the same file does better immediately around it: :207-222 uses it.each + toContainEqual(expect.objectContaining({ path, message })), and the s3BucketMount block (:383, :389, :399) is one named rule per it with expect(messages(result)).toContain(...). The messages() helper already exists.
Also missing, and they're exactly the gap cases from my runtime.ts:559 comment: no test for PUBLIC + absent platformVersion, and none for absent networkMode + V2. Both currently reject; neither is pinned either way, so there's no record of whether that's intended.
Suggested: split the network-mode and platform-version cases into their own named its using messages().
There was a problem hiding this comment.
Fixed in d61d330. Replaced the combined test with focused cases that assert the filesystemConfigurations issue path and exact message for PUBLIC+V1, omitted platform version, and omitted network mode, plus independent EFS/S3 Files, VPC, count, session-storage, and duplicate-path coverage.
| China target fails with an explicit message. Those `add` subcommands say "not available in | ||
| China regions" in their help, and the `agentcore add` menu warns when the project has a China | ||
| deployment target. | ||
| - **PUBLIC filesystem mounts:** The EFS and S3 Files access-point PUBLIC-mode preview is available only in commercial Regions. `agentcore add runtime` rejects PUBLIC EFS or S3 Files mounts when the project targets China, and `agentcore deploy` rechecks the saved runtime configuration. |
There was a problem hiding this comment.
Nit — ~285 chars where this file's prose wraps at ~95. CI won't catch it: printWidth is 100, but prettier's default proseWrap: "preserve" doesn't reflow prose, so format:check passes.
The content itself is accurate and this is the right place for it.
Minor consistency: "commercial Regions" here vs "commercial region" in PUBLIC_BYO_MOUNTS_CN_MESSAGE; lowercase "preview" here vs "(Preview, ...)" in the help.
There was a problem hiding this comment.
Fixed in d61d330. Reflowed the China documentation and aligned commercial-region and Preview casing with the runtime guard message.
28ffb92 to
d61d330
Compare
|
Claude Security Review: no high-confidence findings. (run) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v1.x #2936 +/- ##
==========================================
+ Coverage 96.73% 96.75% +0.01%
==========================================
Files 747 747
Lines 62845 62871 +26
==========================================
+ Hits 60793 60829 +36
+ Misses 2052 2042 -10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Allow
agentcore add runtimeto save Amazon EFS and Amazon S3 Files access-point mounts withnetworkMode: PUBLICandplatformVersion: V2.The CLI keeps VPC validation unchanged, rejects PUBLIC mounts without V2, and rejects the preview for China deployment targets at both add and deploy time. The command help and China-region guide state the preview boundary.
Related Issue
Closes #2930
Documentation PR
Documentation is included in this PR through the CLI help and
docs/china-regions.md.Type of Change
Testing
bun testbun run test:e2e, or explained why they are not applicablebun run typecheckbun run lint:checkbun run format:checkbun run auditbun run secrets:checkbun run buildsrc/assets/, I updated affected snapshots withbun test <test-file> --update-snapshotsand committed themcommand.md(the release workflow regenerates it)Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.