From 26b28631d7ea822f803258fde3fcc7abcbca08bc Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Fri, 20 Nov 2026 12:41:10 -0800 Subject: [PATCH 1/5] feat(deploy): refuse Box projects in regions without AgentCore Runtime 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. --- src/core/partition.test.ts | 24 +++++++++++++++++++++++- src/core/partition.ts | 25 +++++++++++++++++++++++++ src/core/project/boxValidation.ts | 19 ++++++++++++++++++- src/core/project/manager.test.ts | 31 +++++++++++++++++++++++++++++++ src/core/project/manager.tsx | 5 ++++- 5 files changed, 101 insertions(+), 3 deletions(-) diff --git a/src/core/partition.test.ts b/src/core/partition.test.ts index 7275bf0827..69952b2d65 100644 --- a/src/core/partition.test.ts +++ b/src/core/partition.test.ts @@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { isChinaContext, isChinaRegion } from "./partition"; +import { isChinaContext, isChinaRegion, supportsRuntimeV2 } from "./partition"; describe("isChinaRegion", () => { test.each(["cn-north-1", "cn-northwest-1"])("returns true for %s", (region) => { @@ -14,6 +14,28 @@ describe("isChinaRegion", () => { }); }); +describe("supportsRuntimeV2", () => { + // ap-east-9 is not a region: one this CLI does not know of counts as having V2. + test.each(["us-west-2", "us-east-1", "eu-west-1", "cn-north-1", "ap-east-9"])( + "returns true for %s", + (region) => { + expect(supportsRuntimeV2(region)).toBe(true); + }, + ); + + test.each([ + "ap-south-2", + "us-west-1", + "us-gov-west-1", + "us-gov-east-1", + "us-iso-east-1", + "us-isob-east-1", + "us-isof-south-1", + ])("returns false for %s", (region) => { + expect(supportsRuntimeV2(region)).toBe(false); + }); +}); + describe("isChinaContext", () => { let savedRegion: string | undefined; let savedDefaultRegion: string | undefined; diff --git a/src/core/partition.ts b/src/core/partition.ts index e2657d26e9..1c18a7d5c5 100644 --- a/src/core/partition.ts +++ b/src/core/partition.ts @@ -14,6 +14,31 @@ export function isChinaRegion(region: string): boolean { return partition(region).name === "aws-cn"; } +/** + * Regions where AgentCore Runtime offers no platformVersion V2. Box runs only on V2. The source + * of truth is the `runtimeVersion` flag in YggdrasillControlPlaneServiceConfigCDK + * (configuration/dynamic-configuration/feature-flags/prod-.json): a region without it has + * no V2. Remove a region here once V2 launches in it. + */ +const NO_RUNTIME_V2_REGIONS: ReadonlySet = new Set(["ap-south-2", "us-west-1"]); +/** Partitions with no V2 in any region: GovCloud, and the isolated (ADC) partitions. */ +const NO_RUNTIME_V2_PARTITIONS: ReadonlySet = new Set([ + "aws-us-gov", + "aws-iso", + "aws-iso-b", + "aws-iso-f", +]); + +/** + * Whether AgentCore Runtime offers platformVersion V2 in `region`. A region not listed counts as + * having V2, so a new region needs no CLI release; one without V2 fails at CreateAgentRuntime. + */ +export function supportsRuntimeV2(region: string): boolean { + return ( + !NO_RUNTIME_V2_REGIONS.has(region) && !NO_RUNTIME_V2_PARTITIONS.has(partition(region).name) + ); +} + /** * True when the CLI is operating in a China (aws-cn) context: the caller's * resolved region (when provided — telemetry resolves through the same chain diff --git a/src/core/project/boxValidation.ts b/src/core/project/boxValidation.ts index 6339514039..075685ceae 100644 --- a/src/core/project/boxValidation.ts +++ b/src/core/project/boxValidation.ts @@ -3,8 +3,9 @@ * agent with no box. The runtime sync asks the sync rules before it writes agentcore.json, and * build and deploy call {@link validateBoxRuntimes} before they read the box profiles. */ -import { ProjectStateError } from "../../errors/errors"; +import { ProjectStateError, RegionUnsupportedFeatureError } from "../../errors/errors"; import { isBoxProject, type ProjectSpec } from "../../projectSchemas/project"; +import { supportsRuntimeV2 } from "../partition"; import type { ProjectRuntime } from "../../projectSchemas/runtime"; import { BOX_RELEASE } from "./backends/boxRelease"; import { BOX_CODEZIP_ENTRYPOINT, runsInBox } from "./templates/boxProfile"; @@ -100,3 +101,19 @@ export function validateBoxRuntimes(spec: ProjectSpec): void { assertBoxRuntimesHaveBoxVersion(spec); assertBoxCodeZipRuntimesStartBox(spec); } + +/** + * Throws for a Box project deployed to a region where AgentCore Runtime has no platformVersion V2. + * Box runs only on V2, so the runtimes could not be created there. + */ +export function assertBoxRegionSupported( + spec: ProjectSpec, + target: { name: string; region: string }, +): void { + if (!isBoxProject(spec) || supportsRuntimeV2(target.region)) return; + 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.`, + ); +} diff --git a/src/core/project/manager.test.ts b/src/core/project/manager.test.ts index f72d95162e..49476cbcc6 100644 --- a/src/core/project/manager.test.ts +++ b/src/core/project/manager.test.ts @@ -1567,6 +1567,37 @@ describe("FsProjectManager.addResource", () => { expect(deployCalls).toEqual([]); }); + test.each(["ap-south-2", "us-west-1", "us-gov-west-1"])( + "deploy of a Box project to %s fails before anything is written", + async (region) => { + await inTempDirectory(); + const { subject, project, deployCalls } = await projectWithTarget( + region, + undefined, + AGENT_PYTHON_STRANDS_BOX, + ); + const specPath = join(project.rootPath, "agentcore", "agentcore.json"); + const before = await readFile(specPath, "utf8"); + + const { error } = await deployOutcome(subject, project); + expect(error).toBeInstanceOf(RegionUnsupportedFeatureError); + expect(String(error)).toContain( + `Cannot deploy Box project 'example' to target 'primary' in ${region}`, + ); + expect(await readFile(specPath, "utf8")).toBe(before); + expect(deployCalls).toEqual([]); + }, + ); + + test("deploy of a project that is not a Box project to us-west-1 is not refused", async () => { + await inTempDirectory(); + const { subject, project, deployCalls } = await projectWithTarget("us-west-1"); + + const { error } = await deployOutcome(subject, project); + expect(error).toBeUndefined(); + expect(deployCalls).toHaveLength(1); + }); + test("deploy to a China target hard-fails a Bedrock Managed Agents runtime", async () => { await inTempDirectory(); const { subject, project, deployCalls } = await projectWithTarget( diff --git a/src/core/project/manager.tsx b/src/core/project/manager.tsx index 480709beba..58ad142d38 100644 --- a/src/core/project/manager.tsx +++ b/src/core/project/manager.tsx @@ -75,7 +75,7 @@ import { startsInBoxOnCodeZip, } from "./templates/boxProfile"; import { defaultLogTargetNotice } from "./runtimeProfile/rules/additions"; -import { validateBoxRuntimes } from "./boxValidation"; +import { assertBoxRegionSupported, validateBoxRuntimes } from "./boxValidation"; import { BOX_INSTALL_HINT, BOX_RELEASE } from "./backends/boxRelease"; import { getRuntimeTemplateResolver } from "./templates/runtime"; import { @@ -1829,6 +1829,9 @@ export class FsProjectManager implements ProjectManager { ); } + // Box runs only on AgentCore Runtime V2, so stop before the sync rewrites agentcore.json. + assertBoxRegionSupported(project.spec, target); + // Synth reads agentcore.json, so it is brought up to date with the code // first; only once the target is known, so a bad --target rewrites nothing. const synced = await this.syncRuntimeBuilds(project, { purpose: "deploy" }); From 7cee7827abe5a62d92416953c16e31d9e5aee769 Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Fri, 20 Nov 2026 12:46:37 -0800 Subject: [PATCH 2/5] docs(deploy): cite the AgentCore Runtime team for the Runtime V2 region list --- src/core/partition.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/partition.ts b/src/core/partition.ts index 1c18a7d5c5..d45311f5ab 100644 --- a/src/core/partition.ts +++ b/src/core/partition.ts @@ -15,10 +15,8 @@ export function isChinaRegion(region: string): boolean { } /** - * Regions where AgentCore Runtime offers no platformVersion V2. Box runs only on V2. The source - * of truth is the `runtimeVersion` flag in YggdrasillControlPlaneServiceConfigCDK - * (configuration/dynamic-configuration/feature-flags/prod-.json): a region without it has - * no V2. Remove a region here once V2 launches in it. + * Regions where AgentCore Runtime offers no platformVersion V2. Box runs only on V2. The list is + * the AgentCore Runtime team's; remove a region here once V2 launches in it. */ const NO_RUNTIME_V2_REGIONS: ReadonlySet = new Set(["ap-south-2", "us-west-1"]); /** Partitions with no V2 in any region: GovCloud, and the isolated (ADC) partitions. */ From 0961edff0494b89781a2f5c14175e24926e63278 Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Fri, 20 Nov 2026 15:45:09 -0800 Subject: [PATCH 3/5] fix(deploy): Address the review of #2878 - 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. --- src/core/partition.test.ts | 6 +++-- src/core/partition.ts | 7 ++++- src/core/project/boxValidation.ts | 12 ++++++--- src/core/project/manager.test.ts | 45 ++++++++++++++++++++++++++++++- src/core/project/manager.tsx | 6 +++++ 5 files changed, 69 insertions(+), 7 deletions(-) diff --git a/src/core/partition.test.ts b/src/core/partition.test.ts index 69952b2d65..1470bec144 100644 --- a/src/core/partition.test.ts +++ b/src/core/partition.test.ts @@ -15,8 +15,9 @@ describe("isChinaRegion", () => { }); describe("supportsRuntimeV2", () => { - // ap-east-9 is not a region: one this CLI does not know of counts as having V2. - test.each(["us-west-2", "us-east-1", "eu-west-1", "cn-north-1", "ap-east-9"])( + // ap-east-9 is not a region: one this CLI does not know of counts as having V2, as the European + // Sovereign Cloud (eusc-de-east-1) does. + test.each(["us-west-2", "us-east-1", "eu-west-1", "cn-north-1", "ap-east-9", "eusc-de-east-1"])( "returns true for %s", (region) => { expect(supportsRuntimeV2(region)).toBe(true); @@ -31,6 +32,7 @@ describe("supportsRuntimeV2", () => { "us-iso-east-1", "us-isob-east-1", "us-isof-south-1", + "eu-isoe-west-1", ])("returns false for %s", (region) => { expect(supportsRuntimeV2(region)).toBe(false); }); diff --git a/src/core/partition.ts b/src/core/partition.ts index d45311f5ab..5a08b1e05d 100644 --- a/src/core/partition.ts +++ b/src/core/partition.ts @@ -19,11 +19,16 @@ export function isChinaRegion(region: string): boolean { * the AgentCore Runtime team's; remove a region here once V2 launches in it. */ const NO_RUNTIME_V2_REGIONS: ReadonlySet = new Set(["ap-south-2", "us-west-1"]); -/** Partitions with no V2 in any region: GovCloud, and the isolated (ADC) partitions. */ +/** + * Partitions with no V2 in any region: GovCloud, and the isolated (ADC) partitions. The European + * Sovereign Cloud (`aws-eusc`) is left out on purpose: like a region the CLI does not list, it + * counts as having V2, and CreateAgentRuntime refuses it there if it does not. + */ const NO_RUNTIME_V2_PARTITIONS: ReadonlySet = new Set([ "aws-us-gov", "aws-iso", "aws-iso-b", + "aws-iso-e", "aws-iso-f", ]); diff --git a/src/core/project/boxValidation.ts b/src/core/project/boxValidation.ts index 075685ceae..be41507cb3 100644 --- a/src/core/project/boxValidation.ts +++ b/src/core/project/boxValidation.ts @@ -104,16 +104,22 @@ export function validateBoxRuntimes(spec: ProjectSpec): void { /** * Throws for a Box project deployed to a region where AgentCore Runtime has no platformVersion V2. - * Box runs only on V2, so the runtimes could not be created there. + * Box runs only on V2, so the runtimes could not be created there. `target` is a configured target, + * or, with `provisioning`, the default target deploy is about to create in that region. */ export function assertBoxRegionSupported( spec: ProjectSpec, target: { name: string; region: string }, + { provisioning = false }: { provisioning?: boolean } = {}, ): void { if (!isBoxProject(spec) || supportsRuntimeV2(target.region)) return; + const wayOut = provisioning + ? "Deploy with --region set to a region that has it, or add a target in another region to " + + "agentcore/aws-targets.json, then retry." + : `Change the region of target '${target.name}' in agentcore/aws-targets.json, or deploy ` + + "with --target to a target in another region, then retry."; 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.`, + `Box runs on AgentCore Runtime V2, which is not available in ${target.region}. ${wayOut}`, ); } diff --git a/src/core/project/manager.test.ts b/src/core/project/manager.test.ts index 49476cbcc6..386faf3566 100644 --- a/src/core/project/manager.test.ts +++ b/src/core/project/manager.test.ts @@ -1582,13 +1582,56 @@ describe("FsProjectManager.addResource", () => { const { error } = await deployOutcome(subject, project); expect(error).toBeInstanceOf(RegionUnsupportedFeatureError); expect(String(error)).toContain( - `Cannot deploy Box project 'example' to target 'primary' in ${region}`, + `Cannot deploy Box project 'example' to target 'primary' in ${region}: Box runs on ` + + `AgentCore Runtime V2, which is not available in ${region}. Change the region of ` + + "target 'primary' in agentcore/aws-targets.json, or deploy with --target to a target " + + "in another region, then retry.", ); expect(await readFile(specPath, "utf8")).toBe(before); expect(deployCalls).toEqual([]); }, ); + test("deploy of a Box project with no target to us-west-1 fails before STS or aws-targets.json", async () => { + await inTempDirectory(); + const { project } = await projectWithTarget("us-east-1", undefined, AGENT_PYTHON_STRANDS_BOX); + const targetsPath = join(project.rootPath, "agentcore", "aws-targets.json"); + await rm(targetsPath); + const accounts: string[] = []; + const subject = new FsProjectManager({ + logger: createSilentLogger(), + identity: new TestIdentityClient(), + enableTransactionSearch: async () => {}, + boxProfileResolver: new FakeBoxProfileResolver(), + runner: async () => {}, + checkTool: async () => {}, + resolveAccount: async (region) => { + accounts.push(region); + return "111122223333"; + }, + }); + const fresh = (await subject.resolve({ filePath: project.rootPath }))!; + + const deploying = (async () => { + for await (const _ of subject.deploy(fresh, { + target: "default", + region: "us-west-1", + confirmTeardown: async () => false, + })); + })(); + + await expect(deploying).rejects.toThrow( + new RegionUnsupportedFeatureError( + "Cannot deploy Box project 'example' to target 'default' in us-west-1: Box runs on " + + "AgentCore Runtime V2, which is not available in us-west-1. Deploy with --region set " + + "to a region that has it, or add a target in another region to " + + "agentcore/aws-targets.json, then retry.", + ), + ); + expect(accounts).toEqual([]); + expect(existsSync(targetsPath)).toBe(false); + }); + test("deploy of a project that is not a Box project to us-west-1 is not refused", async () => { await inTempDirectory(); const { subject, project, deployCalls } = await projectWithTarget("us-west-1"); diff --git a/src/core/project/manager.tsx b/src/core/project/manager.tsx index 58ad142d38..18bc96edcf 100644 --- a/src/core/project/manager.tsx +++ b/src/core/project/manager.tsx @@ -1801,6 +1801,12 @@ export class FsProjectManager implements ProjectManager { // `default` gets this treatment: inventing a *named* target would turn a // typo'd --target into a deployment somewhere unintended. if (!target && input.target === DEFAULT_TARGET_NAME) { + // Box runs only on AgentCore Runtime V2, so stop before STS or aws-targets.json. + assertBoxRegionSupported( + project.spec, + { name: DEFAULT_TARGET_NAME, region: input.region }, + { provisioning: true }, + ); target = await this.provisionDefaultTarget(project, targetsPath, input.region); yield { type: "step", From 9553bdd1e727010845082af19744e7d4d62f8590 Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Mon, 23 Nov 2026 10:31:12 -0800 Subject: [PATCH 4/5] feat(create): warn about a box template in a region without Runtime V2 create with a box template in a region where AgentCore Runtime has no V2 now warns that the project cannot be deployed there, from the CLI and the wizard alike. It still creates the project: the region at create is often only the one the CLI resolved, and the project can deploy to a target in another region. Deploy stays the hard stop. --- .../project/create/create.screen.test.tsx | 37 +++++++++++++++ src/handlers/project/create/index.ts | 8 +++- src/handlers/project/create/region.ts | 20 +++++++- src/handlers/project/create/screen.tsx | 8 +++- src/handlers/project/project.test.ts | 47 +++++++++++++++++++ 5 files changed, 117 insertions(+), 3 deletions(-) diff --git a/src/handlers/project/create/create.screen.test.tsx b/src/handlers/project/create/create.screen.test.tsx index a0f742fed6..76317f7881 100644 --- a/src/handlers/project/create/create.screen.test.tsx +++ b/src/handlers/project/create/create.screen.test.tsx @@ -1077,6 +1077,43 @@ describe("project create wizard", () => { r.unmount(); }, 10000); + test("template flow: a box template in a region without Runtime V2 warns and still creates", async () => { + const { path: directory, cleanup } = await inTempDirectory(); + cleanups.push(cleanup); + const core = new TestCoreClient(); + spyOnCreate(core); + const r = renderScreen("/agentcore/create", { + core, + withContext: (ctx) => ctx.withValue(RegionKey, "us-west-1"), + }); + + await waitForText(r.lastFrame, "name your project"); + await r.write("SfoApp"); + await r.press("return"); + await waitForText(r.lastFrame, "what kind of agent to start with?"); + await r.press("down"); // code-based + await r.press("return"); + await waitForText(r.lastFrame, "choose a template"); + await r.press("down"); // agent-python-strands-box + await waitForText(r.lastFrame, "● agent-python-strands-box "); + await r.press("return"); + await waitForText(r.lastFrame, "choose a model provider"); + await r.press("return"); // focus the (Bedrock) model id + await waitForText(r.lastFrame, "model ID"); + await r.press("return"); // accept it + await waitForText(r.lastFrame, "how contained should the agent be?"); + await r.press("return"); // sandboxed + await waitForText(r.lastFrame, "this project will be created"); + await r.press("return"); + await waitForText(r.lastFrame, "✔ project created in ./SfoApp", 5000); + + expect(flatFrame(r.lastFrame)).toContain( + "Box runs on AgentCore Runtime V2, which is not available in us-west-1", + ); + expect(existsSync(join(directory, "SfoApp", "agentcore", "agentcore.json"))).toBe(true); + r.unmount(); + }, 10000); + test("template flow: the minimal template scaffolds without memory", async () => { const { path: directory, cleanup } = await inTempDirectory(); cleanups.push(cleanup); diff --git a/src/handlers/project/create/index.ts b/src/handlers/project/create/index.ts index 3d77854231..1fa89a7af1 100644 --- a/src/handlers/project/create/index.ts +++ b/src/handlers/project/create/index.ts @@ -32,7 +32,11 @@ import { InputValidationError, RegionUnsupportedFeatureError } from "../../../er import { JsonKey, RegionKey } from "../../keys"; import { renderResult } from "../../utils"; import { projectReference, type ProjectMutationResult } from "../output"; -import { stripCreateRegionUnavailableDefaults, validateCreateRegionSupport } from "./region"; +import { + boxRegionWarning, + stripCreateRegionUnavailableDefaults, + validateCreateRegionSupport, +} from "./region"; import { chinaModelProviderRestriction } from "../../../core/project/manager"; import { isChinaRegion } from "../../../core/partition"; import { harnessApiKeyCredentialName } from "../../../core/project/templates/harness"; @@ -178,6 +182,8 @@ export const createCreateProjectHandler = (config: CreateProjectHandlerConfig) = } const stripped = stripCreateRegionUnavailableDefaults(createInput, region); if (stripped !== undefined) config.io.stderr.write(`${stripped}\n`); + const boxWarning = boxRegionWarning(createInput, region); + if (boxWarning !== undefined) config.io.stderr.write(`Warning: ${boxWarning}\n`); // Same driver as build and deploy: a live step list in a TTY, and the previous plain // line-per-step output when stderr is not a TTY or --json wants no ANSI on it. diff --git a/src/handlers/project/create/region.ts b/src/handlers/project/create/region.ts index a7def1fb1c..5642a35ade 100644 --- a/src/handlers/project/create/region.ts +++ b/src/handlers/project/create/region.ts @@ -1,10 +1,11 @@ -import { isChinaRegion } from "../../../core/partition"; +import { isChinaRegion, supportsRuntimeV2 } from "../../../core/partition"; import { BMA_CN_MESSAGE, HARNESS_CN_MESSAGE, MEMORY_STRIPPED_CN_MESSAGE, chinaModelProviderRestriction, } from "../../../core/project/manager"; +import { hasBoxProfile } from "../../../core/project/templates/boxProfile"; import { RegionUnsupportedFeatureError } from "../../../errors"; import type { CreateProjectInput } from "../types"; @@ -42,3 +43,20 @@ export function stripCreateRegionUnavailableDefaults( input.scaffoldRuntimeInput.memory = undefined; return MEMORY_STRIPPED_CN_MESSAGE; } + +/** + * The warning create gives for a box template in a region where AgentCore Runtime has no V2, which + * Box needs. Create still makes the project: the region here is often only the one the CLI + * resolved, and the project can deploy to a target in another region. Deploy refuses the region. + * Shared by the CLI and the interactive wizard. Undefined when there is nothing to warn about. + */ +export function boxRegionWarning(input: CreateProjectInput, region: string): string | undefined { + const runtime = input.scaffoldRuntimeInput; + if (runtime === undefined || !hasBoxProfile(runtime) || supportsRuntimeV2(region)) + return undefined; + return ( + `Box runs on AgentCore Runtime V2, which is not available in ${region}, so this project ` + + "cannot be deployed there. Deploy it with --region set to a region that has V2, or to a " + + "target in another region." + ); +} diff --git a/src/handlers/project/create/screen.tsx b/src/handlers/project/create/screen.tsx index f8aa12c3fb..896827b0f5 100644 --- a/src/handlers/project/create/screen.tsx +++ b/src/handlers/project/create/screen.tsx @@ -56,7 +56,11 @@ import { } from "../../../components/wizard"; import { darkTheme } from "../../../components/ui/_core.js"; import { TuiExitMessageKey } from "../../../tui/exitMessage"; -import { stripCreateRegionUnavailableDefaults, validateCreateRegionSupport } from "./region"; +import { + boxRegionWarning, + stripCreateRegionUnavailableDefaults, + validateCreateRegionSupport, +} from "./region"; const theme = darkTheme; @@ -254,6 +258,8 @@ export function ProjectCreateScreen({ ctx, core }: ScreenProps) { validateCreateRegionSupport(input, resolvedRegion); const stripped = stripCreateRegionUnavailableDefaults(input, resolvedRegion); if (stripped !== undefined) yield { type: "step" as const, message: stripped }; + const boxWarning = boxRegionWarning(input, resolvedRegion); + if (boxWarning !== undefined) yield { type: "warning" as const, message: boxWarning }; return yield* core.projectManager.create({ ...input, region: resolvedRegion }); }} runningLabel={`creating ${values.name}…`} diff --git a/src/handlers/project/project.test.ts b/src/handlers/project/project.test.ts index e31d36b7a0..68d923956d 100644 --- a/src/handlers/project/project.test.ts +++ b/src/handlers/project/project.test.ts @@ -172,6 +172,53 @@ describe("project create", () => { expect(spec.runtimes[0].box).toEqual(box); }); + test.each(["us-west-1", "ap-south-2", "us-gov-west-1"])( + "create of a box template in %s warns that it cannot deploy there, and still creates it", + async (region) => { + const { path: directory, cleanup } = await inTempDirectory(); + cleanups.push(cleanup); + const { io } = await run([ + "create", + "--name", + "BoxApp", + "--template", + "agent-python-strands-box", + "--region", + region, + "--skip-install", + "--skip-git", + ]); + + expect(io.stderr()).toContain( + `Warning: Box runs on AgentCore Runtime V2, which is not available in ${region}, so this ` + + "project cannot be deployed there.", + ); + expect(existsSync(join(directory, "BoxApp", "agentcore", "agentcore.json"))).toBe(true); + }, + ); + + test.each([ + ["a box template in us-west-2", "agent-python-strands-box", "us-west-2"], + ["a template that is not a box template in us-west-1", "agent-python-strands", "us-west-1"], + ])("create of %s gives no Runtime V2 warning", async (_name, template, region) => { + const { path: directory, cleanup } = await inTempDirectory(); + cleanups.push(cleanup); + const { io } = await run([ + "create", + "--name", + "BoxApp", + "--template", + template, + "--region", + region, + "--skip-install", + "--skip-git", + ]); + + expect(io.stderr()).not.toContain("AgentCore Runtime V2"); + expect(existsSync(join(directory, "BoxApp", "agentcore", "agentcore.json"))).toBe(true); + }); + test.each(["agent-python-strands", "empty"])( "create --template %s --containment private-vpc is refused and writes nothing", async (template) => { From faea6f255d40e0c457c4aac3aa90263e9efba502 Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Mon, 23 Nov 2026 12:43:30 -0800 Subject: [PATCH 5/5] fix(deploy): Let a Box project with no box runtime deploy anywhere, and name --target when there are targets Addresses Tejas's review of #2878: - A Box project with no runtime was refused in a region without Runtime V2, and deploying an empty project is how its stack is removed, so a stack deployed there by an earlier build could not be torn down. The check now refuses only when a runtime runs in a box. - For the default target, the message names --target when aws-targets.json already has targets, instead of saying to add one. - The Box region tests get their own describe, with one region: the region list itself is partition.test.ts's. --- src/core/project/boxValidation.ts | 23 ++-- src/core/project/manager.test.ts | 170 +++++++++++++++++++----------- src/core/project/manager.tsx | 2 +- 3 files changed, 127 insertions(+), 68 deletions(-) diff --git a/src/core/project/boxValidation.ts b/src/core/project/boxValidation.ts index be41507cb3..7e4f35a4f0 100644 --- a/src/core/project/boxValidation.ts +++ b/src/core/project/boxValidation.ts @@ -103,19 +103,28 @@ export function validateBoxRuntimes(spec: ProjectSpec): void { } /** - * Throws for a Box project deployed to a region where AgentCore Runtime has no platformVersion V2. - * Box runs only on V2, so the runtimes could not be created there. `target` is a configured target, - * or, with `provisioning`, the default target deploy is about to create in that region. + * Throws for a Box project deployed to a region where AgentCore Runtime has no platformVersion V2, + * when one of its runtimes runs in a box: Box runs only on V2, so that runtime could not be created + * there. A Box project with no runtime is let through, as deploying it is how its stack is removed. + * `target` is a configured target, or, with `provisioning`, the default target deploy is about to + * create in that region; `otherTargets` says whether aws-targets.json has targets to deploy to. */ export function assertBoxRegionSupported( spec: ProjectSpec, target: { name: string; region: string }, - { provisioning = false }: { provisioning?: boolean } = {}, + { + provisioning = false, + otherTargets = false, + }: { provisioning?: boolean; otherTargets?: boolean } = {}, ): void { - if (!isBoxProject(spec) || supportsRuntimeV2(target.region)) return; + if (supportsRuntimeV2(target.region)) return; + if (!spec.runtimes.some((runtime) => runsInBox(isBoxProject(spec), runtime))) return; const wayOut = provisioning - ? "Deploy with --region set to a region that has it, or add a target in another region to " + - "agentcore/aws-targets.json, then retry." + ? otherTargets + ? "Deploy with --region set to a region that has it, or with --target set to a target in " + + "another region, then retry." + : "Deploy with --region set to a region that has it, or add a target in another region to " + + "agentcore/aws-targets.json, then retry." : `Change the region of target '${target.name}' in agentcore/aws-targets.json, or deploy ` + "with --target to a target in another region, then retry."; throw new RegionUnsupportedFeatureError( diff --git a/src/core/project/manager.test.ts b/src/core/project/manager.test.ts index 386faf3566..263a2d3ddb 100644 --- a/src/core/project/manager.test.ts +++ b/src/core/project/manager.test.ts @@ -1567,78 +1567,128 @@ describe("FsProjectManager.addResource", () => { expect(deployCalls).toEqual([]); }); - test.each(["ap-south-2", "us-west-1", "us-gov-west-1"])( - "deploy of a Box project to %s fails before anything is written", - async (region) => { + describe("Box projects in a region without Runtime V2", () => { + // partition.test.ts covers which regions have no Runtime V2; one is enough here. + test.each(["us-west-1"])( + "deploy of a Box project to %s fails before anything is written", + async (region) => { + await inTempDirectory(); + const { subject, project, deployCalls } = await projectWithTarget( + region, + undefined, + AGENT_PYTHON_STRANDS_BOX, + ); + const specPath = join(project.rootPath, "agentcore", "agentcore.json"); + const before = await readFile(specPath, "utf8"); + + const { error } = await deployOutcome(subject, project); + expect(error).toBeInstanceOf(RegionUnsupportedFeatureError); + expect(String(error)).toContain( + `Cannot deploy Box project 'example' to target 'primary' in ${region}: Box runs on ` + + `AgentCore Runtime V2, which is not available in ${region}. Change the region of ` + + "target 'primary' in agentcore/aws-targets.json, or deploy with --target to a target " + + "in another region, then retry.", + ); + expect(await readFile(specPath, "utf8")).toBe(before); + expect(deployCalls).toEqual([]); + }, + ); + + // Deploying a project with no runtime is how the CLI removes its stack, so a Box project that was + // deployed to such a region with an earlier build can still be torn down. + test("deploy of a Box project with no runtime to us-west-1 is not refused", async () => { await inTempDirectory(); - const { subject, project, deployCalls } = await projectWithTarget( - region, + const { subject, project } = await projectWithTarget( + "us-west-1", undefined, AGENT_PYTHON_STRANDS_BOX, ); const specPath = join(project.rootPath, "agentcore", "agentcore.json"); - const before = await readFile(specPath, "utf8"); - - const { error } = await deployOutcome(subject, project); - expect(error).toBeInstanceOf(RegionUnsupportedFeatureError); - expect(String(error)).toContain( - `Cannot deploy Box project 'example' to target 'primary' in ${region}: Box runs on ` + - `AgentCore Runtime V2, which is not available in ${region}. Change the region of ` + - "target 'primary' in agentcore/aws-targets.json, or deploy with --target to a target " + - "in another region, then retry.", + const spec = JSON.parse(await readFile(specPath, "utf8")); + await writeFile( + specPath, + JSON.stringify({ ...spec, runtimes: [], agentCoreGateways: [], memories: [] }, null, 2), ); - expect(await readFile(specPath, "utf8")).toBe(before); - expect(deployCalls).toEqual([]); - }, - ); - test("deploy of a Box project with no target to us-west-1 fails before STS or aws-targets.json", async () => { - await inTempDirectory(); - const { project } = await projectWithTarget("us-east-1", undefined, AGENT_PYTHON_STRANDS_BOX); - const targetsPath = join(project.rootPath, "agentcore", "aws-targets.json"); - await rm(targetsPath); - const accounts: string[] = []; - const subject = new FsProjectManager({ - logger: createSilentLogger(), - identity: new TestIdentityClient(), - enableTransactionSearch: async () => {}, - boxProfileResolver: new FakeBoxProfileResolver(), - runner: async () => {}, - checkTool: async () => {}, - resolveAccount: async (region) => { - accounts.push(region); - return "111122223333"; - }, + const { error } = await deployOutcome(subject, project); + expect(error).not.toBeInstanceOf(RegionUnsupportedFeatureError); }); - const fresh = (await subject.resolve({ filePath: project.rootPath }))!; - const deploying = (async () => { - for await (const _ of subject.deploy(fresh, { - target: "default", - region: "us-west-1", - confirmTeardown: async () => false, - })); - })(); + test("deploy of a Box project with no target to us-west-1 fails before STS or aws-targets.json", async () => { + await inTempDirectory(); + const { project } = await projectWithTarget( + "us-east-1", + undefined, + AGENT_PYTHON_STRANDS_BOX, + ); + const targetsPath = join(project.rootPath, "agentcore", "aws-targets.json"); + await rm(targetsPath); + const accounts: string[] = []; + const subject = new FsProjectManager({ + logger: createSilentLogger(), + identity: new TestIdentityClient(), + enableTransactionSearch: async () => {}, + boxProfileResolver: new FakeBoxProfileResolver(), + runner: async () => {}, + checkTool: async () => {}, + resolveAccount: async (region) => { + accounts.push(region); + return "111122223333"; + }, + }); + const fresh = (await subject.resolve({ filePath: project.rootPath }))!; + + const deploying = (async () => { + for await (const _ of subject.deploy(fresh, { + target: "default", + region: "us-west-1", + confirmTeardown: async () => false, + })); + })(); + + await expect(deploying).rejects.toThrow( + new RegionUnsupportedFeatureError( + "Cannot deploy Box project 'example' to target 'default' in us-west-1: Box runs on " + + "AgentCore Runtime V2, which is not available in us-west-1. Deploy with --region set " + + "to a region that has it, or add a target in another region to " + + "agentcore/aws-targets.json, then retry.", + ), + ); + expect(accounts).toEqual([]); + expect(existsSync(targetsPath)).toBe(false); + }); - await expect(deploying).rejects.toThrow( - new RegionUnsupportedFeatureError( - "Cannot deploy Box project 'example' to target 'default' in us-west-1: Box runs on " + - "AgentCore Runtime V2, which is not available in us-west-1. Deploy with --region set " + - "to a region that has it, or add a target in another region to " + - "agentcore/aws-targets.json, then retry.", - ), - ); - expect(accounts).toEqual([]); - expect(existsSync(targetsPath)).toBe(false); - }); + test("deploy of a project that is not a Box project to us-west-1 is not refused", async () => { + await inTempDirectory(); + const { subject, project, deployCalls } = await projectWithTarget("us-west-1"); - test("deploy of a project that is not a Box project to us-west-1 is not refused", async () => { - await inTempDirectory(); - const { subject, project, deployCalls } = await projectWithTarget("us-west-1"); + const { error } = await deployOutcome(subject, project); + expect(error).toBeUndefined(); + expect(deployCalls).toHaveLength(1); + }); - const { error } = await deployOutcome(subject, project); - expect(error).toBeUndefined(); - expect(deployCalls).toHaveLength(1); + test("names --target, not a new target, when aws-targets.json has targets", async () => { + await inTempDirectory(); + const { subject, project } = await projectWithTarget( + "us-west-2", + undefined, + AGENT_PYTHON_STRANDS_BOX, + ); + const fresh = (await subject.resolve({ filePath: project.rootPath }))!; + + const deploying = (async () => { + for await (const _ of subject.deploy(fresh, { + target: "default", + region: "us-west-1", + confirmTeardown: async () => false, + })); + })(); + + await expect(deploying).rejects.toThrow( + "Deploy with --region set to a region that has it, or with --target set to a target in " + + "another region, then retry.", + ); + }); }); test("deploy to a China target hard-fails a Bedrock Managed Agents runtime", async () => { diff --git a/src/core/project/manager.tsx b/src/core/project/manager.tsx index 06c6732cd7..e8e8a4c2c1 100644 --- a/src/core/project/manager.tsx +++ b/src/core/project/manager.tsx @@ -1821,7 +1821,7 @@ export class FsProjectManager implements ProjectManager { assertBoxRegionSupported( project.spec, { name: DEFAULT_TARGET_NAME, region: input.region }, - { provisioning: true }, + { provisioning: true, otherTargets: targets.length > 0 }, ); target = await this.provisionDefaultTarget(project, targetsPath, input.region); yield {