Takomo
  • What is Takomo?
  • Getting started
    • Installation
    • Quick start
    • Tutorial
  • Configuration
    • AWS credentials
    • Directory structure
    • Stacks and stack groups
    • Project configuration
  • Stack properties
    • Name
    • Regions
    • Template
    • Template bucket
    • Command role
    • Account ids
    • Depends
    • Parameters
    • Tags
    • Inherit tags
    • Termination protection
    • Timeout
    • Capabilities
    • Stack policy
    • Ignore
    • Obsolete
    • Hooks
    • Data
    • Schemas
  • Variables and templating
    • Introduction
    • Handlebars syntax
    • Environment variables
    • Command-line variables
    • Partials
    • Helpers
    • Available variables
  • Parameter resolvers
    • Built-in parameter resolvers
      • Stack output resolver
      • External stack output resolver
      • Command resolver
      • File contents resolver
      • Hook output resolver
      • SSM parameter resolver
      • Secret resolver
    • Custom parameter resolvers
  • Hooks
    • Built-in hooks
    • Custom hooks
    • Sharing data between hooks
  • Validation schemas
    • Custom validation schemas
  • Command-line usage
    • Common options
    • Deploy stacks
    • Undeploy stacks
    • Prune stacks
    • List stacks
    • Detect drift
    • Generate IAM policies
    • Inspect stack configuration
    • Inspect stack dependencies
  • Support
    • Getting help
    • Troubleshooting
  • Development
    • Change log
Powered by GitBook
On this page
  • Usage
  • Positional arguments
  • Options
  • IAM permissions
  • Examples

Was this helpful?

Export as PDF
  1. Command-line usage

Prune stacks

PreviousUndeploy stacksNextList stacks

Last updated 3 years ago

Was this helpful?

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.

Usage

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.

Options

In addition to the , 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.
Statement: 
  - Sid: Stacks
    Effect: Allow
    Action:
      - 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
    Action:
      - sts:AssumeRole
    Resource: "*" 

Examples

Prune all stacks:

tkm stacks prune

Prune 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
common options