Skip to content

Hard-coded CDKToolkit stack name causes false bootstrap prompt #1799

Closed

Description

@pluralistix

Description

agentcore deploy checks for a CloudFormation stack named exactly CDKToolkit:

export const CDK_TOOLKIT_STACK_NAME = 'CDKToolkit';

new DescribeStacksCommand({
  StackName: CDK_TOOLKIT_STACK_NAME,
});

This breaks in environments where CDK bootstrap infrastructure is deployed centrally, for example through CloudFormation StackSets, which create stack names such as:

StackSet-CDKToolkit-9afdf51a-b1cf-4dfc-9b0c-63ccafe70cbc

The environment is already bootstrapped, but AgentCore still prompts:

Bootstrap AWS environment

In interactive mode, this prompt can be cancelled and deployment continues successfully. In CI/CD, there is no clean equivalent.

Expected behavior

AgentCore should support externally managed bootstrap infrastructure without assuming ownership of it.

A minimal fix would be:

agentcore deploy --skip-bootstrap-check

or a configuration option such as:

{
  "bootstrap": {
    "management": "external"
  }
}

In this mode, AgentCore must not:

  • require a stack named CDKToolkit
  • create bootstrap infrastructure
  • update existing bootstrap infrastructure
  • assume ownership of a detected bootstrap stack

Making the stack name configurable alone is not sufficient, because detection must not imply permission to manage that stack.

Steps to Reproduce

  1. Bootstrap an AWS account and region through CloudFormation StackSets

  2. Ensure the resulting bootstrap stack has a generated name, for example:

    StackSet-CDKToolkit-9afdf51a-b1cf-4dfc-9b0c-63ccafe70cbc
    
  3. Configure AgentCore to deploy to the same account and region.

  4. Run:

    agentcore deploy
  5. Observe that AgentCore prompts to bootstrap the AWS environment.

  6. Cancel the bootstrap prompt.

  7. Observe that the deployment continues successfully using the existing bootstrap infrastructure.

Expected Behavior

agentcore deploy should not report that bootstrapping is required when a usable CDK bootstrap environment already exists.

The bootstrap check should not depend exclusively on a CloudFormation stack named exactly CDKToolkit.

AgentCore should also provide a way to mark bootstrap infrastructure as externally managed, ensuring that the CLI does not attempt to create or update it.

Actual Behavior

agentcore deploy checks only for a CloudFormation stack named exactly CDKToolkit.

If the bootstrap infrastructure was provisioned through CloudFormation StackSets and the resulting stack has a generated name, AgentCore reports that the environment needs to be bootstrapped.

In interactive mode, the bootstrap prompt can be cancelled and the deployment continues successfully using the existing bootstrap infrastructure.

CLI Version

No response

Operating System

Linux

Additional Context

No response

Activity

  1. added
    bug
    on Jul 21, 2026
  2. caviliar commented on Sep 21, 2026

    @caviliar

    We are hitting this too, and it currently blocks us. Our developers do not have permission to deploy directly into production accounts; every deploy goes through a CI/CD pipeline that runs agentcore deploy --target <t> --yes non-interactively with the pipeline's role. Because the bootstrap check fails there, and there is no interactive prompt to cancel, we cannot ship AgentCore projects to production at all right now.

    Our accounts are bootstrapped by an org-wide provisioning tool that gives the toolkit stack its own name (<tool>-cdktoolkit-<account-alias>). The environment is fully bootstrapped — default qualifier hnb659fds, /cdk-bootstrap/hnb659fds/version = 30 — yet the deploy (0.28.0/0.30.0) stops at:

    ✗ Check bootstrap status
    AWS environment needs bootstrapping. Run with --yes to auto-bootstrap.
    

    We are already passing --yes, so that hint is a dead end for CI. Interactively (which only a few admins can do), cancelling the bootstrap prompt lets the deploy finish, as you describe.

    A few observations from reading the code that I think sharpen the fix:

    1. 0.x (main, src/cli/cloudformation/bootstrap.ts): besides the hardcoded CDKToolkit, checkBootstrapNeeded probes awsTargets[0], not the target selected with --target. With several targets in aws-targets.json, the check runs against the wrong account/region.
    2. 1.0 RC (src/core/project/backends/cdk/environment.ts, cdk.ts): the name is still hardcoded, and when the probe returns absent the deploy now bootstraps unconditionally (no prompt, no --yes gate). In a centrally bootstrapped account that runs cdk bootstrap with the default qualifier against resources the external stack already owns (assets bucket, /cdk-bootstrap/hnb659fds/version), so the deploy fails on a CloudFormation resource collision instead of just prompting. The interactive escape hatch is gone in 1.0, so this becomes a hard blocker for anyone with a StackSet / Control Tower / custom central bootstrap.
    3. @aws-cdk/toolkit-lib already exposes toolkitStackName on its bootstrap/deploy/environment options (default CDKToolkit), and CdkBackendConfig already has a bootstrap: BootstrapProbe seam. So the plumbing is mostly there.

    Proposed shape, per deployment target in aws-targets.json:

    {
      "name": "production",
      "account": "123456789012",
      "region": "eu-central-1",
      "bootstrap": {
        "stackName": "central-cdktoolkit-production",
        "managed": false
      }
    }
    • bootstrap.stackName (default CDKToolkit): used by the probe and passed as toolkitStackName to the Toolkit.
    • bootstrap.managed (default true): when false, the CLI never creates or updates the bootstrap stack. An absent/outdated probe result becomes an actionable error ("environment is externally bootstrapped and not current; ask the account owner to upgrade"), which matches the "detection must not imply ownership" point above.
    • Probe the target selected by --target, not awsTargets[0].

    Or either of the two options provided in the issue as possible fixes would also suffice.

    Happy to open a PR against main (Closes #1799) with this if maintainers agree on the shape — or adjust to whatever field naming you prefer.

  3. zeplynne commented on Sep 30, 2026

    @zeplynne

    @caviliar We are in the exact same boat. We have been using a custom qualifier and stack names for years. I assume if the AgentCore CLI team had talked to the CDK team while designing this or any active development, they would know that many institutions are not using the default qualifier of hnb659fds nor hard-coded stack names, etc. These are giant breaking changes full-stop. The only way around is to take what AgentCore builds and then rewrite it via automation so it works in our environments. This defeats the rapid build and deployment of agents this tool is supposed to provide.

    Hoping they do these 2 one day, for now we hack the original and make it our own after the cli builds it.

    1. Ability to add our Aspects to the agent core stack. Ideally this is some kind of interface contract where it is clear what parts of the cdk we can touch without modifying the internals of the agent core provided cdk.
    2. Ability to add our own resources to an agent. If we have an agent that needs access to other AWS services, we will often want to define that in the same stack. This helps keep everything in defined permission boundaries we have.
  4. self-assigned this
    on Oct 23, 2026
  5. added a commit that references this issue on Nov 11, 2026
    0b5b967
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bughigh-severity

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions