using the AWS CDK command line how can I destroy stacks concurrently

0

When I destroy stacks using the cdk command, i.e.,

cdk destroy *Stack

even thought the wildcard *Stack matches multiple stacks, only one of the matched stacks is destroyed at a time. I note that for the deploy command we have --concurrency and but there is no corresponding option for the destroy command.

How can I destroy stacks in parallel?

3 réponses
0

Hi,

Stacks created by CDK may have cross-dependencies.

See https://medium.com/life-at-apollo-division/resolve-aws-cdk-stack-dependency-conflicts-c6a3dee0c28d

So, the order of their destruction matters if you want to end up with a clean situation: i.e all resources created automatically by the stacks also get destroyed automatically. You don't want to keep some resources active because stacks were deleted in incorrect order.

That is why CDK give us less control on stack destruction, in particular in parallel.

Best,

Didier

profile pictureAWS
EXPERT
répondu il y a 8 mois
  • Thanks Didier.

    I understand what you are saying though i'm a little surprised by it. It's certainly true that I have stack dependencies, but when deploying, the CDK must understand those dependencies to an extent as it can deploy independent stacks concurrently, so why can't it also do so when destroying?

0

Hello.

I think if you add "--all" to the option, all stacks will be deleted.
Also, doesn't it work if you surround the wildcard with quotes?
https://docs.aws.amazon.com/cdk/v2/guide/cli.html#cli-stacks

You may also use the --all option to specify all stacks.
When using wildcards, enclose the pattern in quotes, or escape the wildcards with . If you don't, your shell may try to expand the pattern to the names of files in the current directory. At best, this won't do what you expect; at worst, you could deploy stacks you didn't intend to. This isn't strictly necessary on Windows because cmd.exe does not expand wildcards, but is good practice nonetheless.

profile picture
EXPERT
répondu il y a 8 mois
0

Thanks, for your suggestion, but unfortunately it doesn't address my use case.

Firstly, the wildcard matching is working, and does destroy all stacks that match the pattern, but not concurrently.

Secondly, I don't want to destroy all stacks, which the -all option would do, just those that match my pattern.

répondu il y a 8 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions