Skip to main content

Prune stacks

Undeploy (remove) stacks marked as obsolete within the given command path.

Takomo also removes obsolete stacks that depend on the obsolete stacks within the command path, even if they are outside the given command path. Takomo arranges the stacks in removal order by stack dependencies, ensuring that it removes the stacks in the correct order and in parallel when possible. Obsolete stacks can't have dependent stacks that are not obsolete themselves


tkm stacks prune [command-path] \
[--ignore-dependencies] \
[--interactive|-i] \
[--output <format>]

Positional arguments

  • command-path
    • Command path to select which stacks to prune.
    • Optional, by default, Takomo prunes all stacks.


In addition to the common options, this command has the following options.

  • --ignore-dependencies
    • Ignore stack dependencies. By default, when a stack is removed, its dependants are removed first, and then the stack itself. In some exceptional cases, you might want to remove just one stack and skip its dependants.
    • Bear in mind that this option is supported only when exactly one stack is removed. Ignoring dependants may lead into unexpected results, so you should use this option only in exceptional circumstances.
  • --interactive, -i
    • Choose the command path using autocompleting search.
  • --output <format>
    • Print the command result using this format
    • Supported values: text, json, yaml

IAM permissions

These are the minimum IAM permissions required to run this command.

# Minimum permissions. Additional permissions are needed to actually 
# remove the resources defined in CloudFormation templates.
- Sid: Stacks
Effect: Allow
- cloudformation:DescribeStackEvents
- cloudformation:DeleteStack
- cloudformation:DescribeStacks
Resource: "*"

# IAM permissions needed only if command roles are used
# Specify resource to restrict access to specific roles.
- Sid: IAM
Effect: Allow
- sts:AssumeRole
Resource: "*"


Prune all obsolete stacks:

tkm stacks prune

Prune obsolete stacks within the given command path:

tkm stacks prune /dev

Prune only /dev/vpc.yml stack and its dependants:

tkm stacks prune /dev/vpc.yml

The region part must be specified if the stack has more than one region and you want to prune it from only one region.

tkm stacks prune /dev/vpc.yml/eu-west-1

Prune exactly one stack and skip its dependants:

tkm stacks prune /cloudtrail.yml --ignore-dependencies