Skip to content

First interactive deploy of a fresh project fails: "Stack selection is ambiguous, please choose a specific stack for import" #1752

Description

@jesseturner21

Describe the bug

The very first agentcore deploy (interactive TUI mode) on a freshly created project fails immediately after synth:

[13:41:25] STEP: Publish assets
[13:41:25] [trace] CDK_TOOLKIT_I1001: Starting Synthesis ...
[13:41:25] [debug] CDK_ASSEMBLY_I0150: --app points to a cloud assembly, so we bypass synth
[13:41:25] [info] CDK_TOOLKIT_I1000: ✨  Synthesis time: 0.01s
[13:41:25] Error: CDK deploy failed: Stack selection is ambiguous, please choose a specific stack for import [AgentCore-clitest-default]
[13:41:25] Status: FAILED

Re-running deploy a second time succeeds, which masks the bug.

To reproduce

  1. agentcore create --name clitest
  2. cd clitest && agentcore deploy (interactive, no flags)

Root cause

Regression from the #1267 fix (#1659). The TUI deploy flow now scopes its stack selector to the target picker's selection (useDeployFlow.ts builds a PATTERN_MUST_MATCH selector from selectedTargets), and deliberately treats an empty selection as "deploy nothing".

A fresh project has an empty aws-targets.json, so useAwsTargetConfig takes the auto-detect path: it detects the AWS account/region and writes a default target — but unlike the single-pre-configured-target and multi-target-picker paths, it never populates selectedTargetIndices. DeployScreen then passes selectedTargets = [] into the deploy flow, producing a PATTERN_MUST_MATCH selector with zero patterns, and toolkit-lib throws NoStacksMatched ("Stack selection is ambiguous...").

On the second run aws-targets.json has one entry, so the single-target path selects index 0 and deploy works — every first deploy of a new project is broken.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions