Repository navigation
feat(deploy): refuse Box projects in regions without AgentCore Runtime V2 - #2878
mquang-amazon wants to merge 3 commits into
Conversation
…e V2 Box runs only on AgentCore Runtime V2 (platformVersion V2). Deploy now refuses a Box project whose target is in a region without V2 (ap-south-2, us-west-1, GovCloud, and the isolated partitions), before the runtime sync rewrites agentcore.json. Other regions, including new ones the CLI does not know, are allowed.
leo237
left a comment
There was a problem hiding this comment.
Thanks for this. The check is small and in the right place: deploy() resolves exactly one target (--target, or the synthesized default), and assertBoxRegionSupported runs on that target's region before syncRuntimeBuilds, applyBoxNetwork and the backend. Every later step reads target.region, so no other region source (such as AWS_REGION) gets past the check. A multi-target project is refused only for the bad target. The manager test confirms that agentcore.json stays unchanged and that the backend is never called. The unit tests cover every denylisted region and partition and pass a region the CLI does not know. Failing open for unknown regions is documented, and I think it is the right choice. The must-survive Box fixes (assertBoxRuntimesHaveBoxVersion / runtimeRunsInBox, per-runtime profiles, --containment, the logs notice) are untouched.
Resolved during review
- Internal names in a committed code comment. The first commit's JSDoc in
src/core/partition.tsnamed an internal-only package and a config path.ceb0a75bremoved them, so the current head is clean. That first commit still has the text, so please squash-merge, which keeps it out of thebox-integrationhistory.
Non-blocking (approving; none of these block)
- PR description: please remove the internal-only links. The "Where the region list comes from" section links to internal source and config files and names internal flags and validators. Please drop those links and names from the public description. The public AgentCore Regions link plus a short sentence is enough.
- Default-target path runs before the check. When no target exists and
--targetisdefault,provisionDefaultTargetcalls STS (resolveAccount) and writesagentcore/aws-targets.json, and only then does the new check refuse. So "before any build or AWS call" in the description holds only for configured targets. This does no harm, and the message tells the user to edit that file. Still, you could runsupportsRuntimeV2(input.region)for a Box project before provisioning, or reword the description. A test for this path (noaws-targets.json, Box project,region: "us-west-1") would pin whichever behavior you choose. aws-iso-eandaws-euscare not in the partition denylist. The SDK partition data the CLI uses (@aws-sdk/core3.978.0) definesaws-iso-e(eu-isoe-*) andaws-eusc(eusc-de-*) as well. Neither is denylisted, so they count as having V2. The comment says "the isolated partitions", butaws-iso-eis missing from that set. If leaving them out is intended (fail-open), please say so in the comment. Otherwise add them, and add aneu-isoe-west-1case to the test.- Error message wording. "Set a target in another region in agentcore/aws-targets.json" has the right path, but it is a bit vague. Something like "Change the region of target 'primary' in agentcore/aws-targets.json, or deploy with --target to a target in another region" names both ways out.
- Create/add do not warn.
agentcore create/addof a Box project with--region us-west-1still succeed, and the user learns about the problem only at deploy. A follow-up notice at create time would be friendly. This is out of scope here. - Branch hygiene. The branch is a few commits behind
box-integration(no conflicts). The change is not onbox-integration-development, so it will need a back-merge there to keep the two branches in sync. The CDK follow-up that pinsPlatformVersion: "V2"is fine as a separate PR.
CI at review time: CodeQL: pass; verify / Linux: pending; verify / Windows: pending; verify / macOS: pending; Analyze: pass; AWS CodeBuild us-east-1 (agentcore-e2e): pass. Please merge only after verify is green on all three OSes.
| * the AgentCore Runtime team's; remove a region here once V2 launches in it. | ||
| */ | ||
| const NO_RUNTIME_V2_REGIONS: ReadonlySet<string> = new Set(["ap-south-2", "us-west-1"]); | ||
| /** Partitions with no V2 in any region: GovCloud, and the isolated (ADC) partitions. */ |
There was a problem hiding this comment.
Non-blocking: the SDK partition data also defines aws-iso-e (eu-isoe-*), and aws-eusc too. They are not in this set, so they count as having V2. If that is intended, please say so in the comment. Otherwise add them, and add an eu-isoe-west-1 test case.
There was a problem hiding this comment.
Done in 6f78b4f: aws-iso-e is in the set, with an eu-isoe-west-1 case. aws-eusc is left out on purpose, and the comment says so: like a region the CLI does not list, it counts as having V2 (fail open), with an eusc-de-east-1 case pinning that.
| } | ||
|
|
||
| // Box runs only on AgentCore Runtime V2, so stop before the sync rewrites agentcore.json. | ||
| assertBoxRegionSupported(project.spec, target); |
There was a problem hiding this comment.
Non-blocking: this check is in the right place for a configured target. But for a fresh project, provisionDefaultTarget (above) has already called STS and written aws-targets.json by the time we get here. You could check input.region for a Box project before provisioning, or reword "before any AWS call" in the description. Either way, a test for the default-target path would pin it.
There was a problem hiding this comment.
Done in 6f78b4f: a Box project is checked against input.region before provisionDefaultTarget, so an unsupported region makes no STS call and writes no aws-targets.json. A test covers that path (no aws-targets.json, Box project, us-west-1): resolveAccount is never called and the file is not written.
| throw new RegionUnsupportedFeatureError( | ||
| `Cannot deploy Box project '${spec.name}' to target '${target.name}' in ${target.region}: ` + | ||
| `Box runs on AgentCore Runtime V2, which is not available in ${target.region}. ` + | ||
| `Set a target in another region in agentcore/aws-targets.json, then retry.`, |
There was a problem hiding this comment.
Nit: maybe "Change the region of target '' in agentcore/aws-targets.json, or deploy with --target to a target in another region, then retry." That names both ways out.
There was a problem hiding this comment.
Done in 6f78b4f: "Change the region of target '' in agentcore/aws-targets.json, or deploy with --target to a target in another region, then retry." For the default target that deploy would create, it says to deploy with --region, or add a target in another region.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## box-integration #2878 +/- ##
===================================================
+ Coverage 96.78% 96.79% +0.01%
===================================================
Files 766 766
Lines 66590 66800 +210
===================================================
+ Hits 64452 64662 +210
Misses 2138 2138 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- Refuse a Box project before deploy provisions the default target, so an unsupported --region makes no STS call and writes no aws-targets.json. - Add aws-iso-e to the partitions with no Runtime V2, and say that the European Sovereign Cloud counts as having it, as an unknown region does. - The error names both ways out: change the target's region, or deploy with --target to another target; for the default target, --region.
leo237
left a comment
There was a problem hiding this comment.
Re-review of 6f78b4f. Still approved. Please merge only after verify / Linux|Windows|macOS pass; they were pending when I posted. CodeQL, Analyze and the CodeBuild e2e job pass.
Addressed
- Ordering: for a new project, the check now runs before
provisionDefaultTarget, so a refused region makes no STS call and writes noaws-targets.json. The new test checks both:resolveAccountis never called and the file does not exist afterwards. - Partitions:
aws-iso-eis now on the denylist. I checked the SDK version this repo locks (@aws-sdk/core3.978.0 partition data): it mapseu-isoe-west-1toaws-iso-eandeusc-de-east-1toaws-eusc, so both new test cases test real behavior. Leavingaws-euscoff on purpose, with a comment saying why, is a reasonable choice. - Error message: it now names both fixes (change the target's region, or use
--target), and the default-target case gets a--regionhint. The tests assert the full text. - Commit messages: no internal references.
Still open (non-blocking)
- PR description: it still names an internal planning doc under "Related Issue". Please replace that with a generic line. The description is also out of date: it shows the old error text, leaves out
aws-iso-e, and still says "before any build or AWS call" without mentioning the default-target case. - A friendly warning in
create/addfor a Box project in a blocked region is still a follow-up. - Please squash-merge and back-merge to
box-integration-development, as discussed.
FYI
The branch merges cleanly into box-integration (it is 21 commits behind). A trial merge with #2879 conflicts in boxValidation.ts and manager.test.ts; manager.tsx auto-merges. Whichever PR lands second will need a rebase.
Description
Box runs only on AgentCore Runtime V2 (
platformVersion: "V2").agentcore deploynow refuses aBox project (
"projectType": "box") whose target is in a region without V2. The check runs assoon as the target is known, before the runtime sync rewrites
agentcore.jsonand before anybuild or AWS call:
Blocked:
ap-south-2(Hyderabad),us-west-1(N. California), theaws-us-govpartition, andthe isolated partitions (
aws-iso,aws-iso-b,aws-iso-f). The list is a denylist insrc/core/partition.ts(supportsRuntimeV2), so a region the CLI does not know counts as havingV2 and needs no CLI release; remove a region from the list once V2 launches there. Projects that
are not Box projects are unaffected.
Where the region list comes from
AgentCore Runtime rejects
platformVersion: "V2"withPLATFORM_VERSION_V2_NOT_AVAILABLEin aregion where V2 has not launched. The AgentCore Runtime team confirmed that V2 is available in
every region where AgentCore Runtime is
(https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/agentcore-regions.html) except
Hyderabad (
ap-south-2), N. California (us-west-1) and AWS GovCloud. It is not available in theisolated partitions either. China (
cn-north-1,cn-northwest-1) has V2, so it is not blocked.A follow-up in the CDK library pins
PlatformVersion: "V2"on the runtimes of a Box project. Withthat pin, CloudFormation would also fail in these regions, but only after build and upload, and
with a stack rollback instead of this message.
Related Issue
No GitHub issue. Tracked in the Beatbox plan ("Bugs, Findings, AIs", "support Box on Runtime V2 in
V2 supported regions alone").
Documentation PR
Not applicable.
Type of Change
Testing
How have you tested the change?
bun test:src/core/partition.test.tsandsrc/core/project/manager.test.tspass(231 tests). The full run has 31 failures that also fail without this change; my local
node_moduleshas@aws-sdk/client-bedrock-agentcore3.1153.0 instead of^3.1171.0.bun run test:e2e, or explained why they are not applicable(CI does not run them for you): not run; the check fires before any AWS call.
bun run typecheck: no errors in the changed files; the 53 errors it reports also occurwithout this change (same stale SDK).
bun run lint:checkbun run format:check: the changed files are formatted (the pre-commit hook ranPrettier on them).
bun run auditbun run secrets:checkbun run buildsrc/assets/, I updated affected snapshots withbun test <test-file> --update-snapshotsand committed themby this PR
command.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.