Skip to content

cdk destroy: No stack found in the main cloud assembly #32836

@cporte

Description

@cporte

Please add your +1 👍 to let us know you have encountered this


Status: RESOLVED

Overview:

In version 2.175.0, running cdk destroy <wildcard-pattern>, with an application not containing any stacks at the top-level assembly, but only in nested stages, fails with the following error:

No stack found in the main cloud assembly. Use "list" to print manifest

Workaround:

Downgrade to 2.174.1 or upgrade to 2.175.1, or add an unused stack directly under the App.

Solution:

Downgrade to 2.174.1 or upgrade to 2.175.1.

Related Issues:


Original issue

Describe the bug

Hello,

Since the version 2.175.0 of the CLI we can no longer run cdk destroy.

Run cdk destroy --force true 'Dev*/*'

No stack found in the main cloud assembly. Use "list" to print manifest

While cdk list does yield some result:

`cdk list` 
  
LocalStage/NetworkStack (LocalStage-NetworkStack)
DevStage/NetworkStack (DevStage-NetworkStack)

The problem is not related to the wildcard nor the specific stack naming.
(Same result with cdk destroy --all or cdk destroy 'DevStage/NetworkStack'

One specificity that might explain the issue, we are using the cdk.Stage class to organize our stacks, but we are not using the CodePipeline constructs (our CI/CD runs outside of AWS and calls the cdk commands using the wildcards)

We didn't try without this code structuration.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

2.174.1

Expected Behavior

Similar to 2.174.1 and before, it is expected to run the stack destruction for the given stacks (or all if --all is specified)

Current Behavior

the cdk destroy commands yield an error:
No stack found in the main cloud assembly. Use "list" to print manifest

Reproduction Steps

import * as cdk from 'aws-cdk-lib';
import * as s3 from 'aws-cdk-lib/aws-s3';
import {Construct} from 'constructs';

const devEnv = {account: 'XXXXXXXXXXXX', region: 'eu-central-1'};
const app = new cdk.App();

export class DevStage extends cdk.Stage {
  constructor(scope: Construct, id: string, props: cdk.StageProps) {
    super(scope, id, props);

    const networkStack = new NetworkStack(this, 'NetworkStack', {
      env: props.env
    });
  }
}

export class NetworkStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props: cdk.StackProps) {
    super(scope, id, props);

    new s3.Bucket(this, `MyBucket`, {
      autoDeleteObjects: true,
      removalPolicy: cdk.RemovalPolicy.DESTROY
    });
  }
}

new DevStage(app, 'DevStage', {env: devEnv});

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.175.0

Framework Version

No response

Node.js Version

20.18.1

OS

Ubuntu 24.04

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.cliIssues related to the CDK CLIeffort/mediumMedium work item – several days of effortmanagement/trackingIssues that track a subject or multiple issuesp0package/toolsRelated to AWS CDK Tools or CLIpotential-regressionMarking this issue as a potential regression to be checked by team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions