Skip to main content

Component-Aware Stack Tab Completion

· 2 min read
Erik Osterman
Founder @ Cloud Posse

Tab completion for the --stack flag is now context-aware, filtering suggestions based on the component you specify.

What Changed​

When running Terraform commands like atmos terraform plan <component> --stack <TAB>, the shell completion now intelligently filters stack suggestions to only show stacks that contain the specified component.

Before:

$ atmos terraform plan vpc --stack <TAB>
dev prod staging test-1 test-2 # All stacks shown

After:

$ atmos terraform plan vpc --stack <TAB>
dev prod # Only stacks containing the vpc component

Why This Matters​

This enhancement improves the developer experience by:

  • Scales with your infrastructure - In large organizations with hundreds of stacks, you only see the handful that are relevant
  • Reducing cognitive load - No more scrolling through dozens or hundreds of irrelevant stacks
  • Preventing errors - Impossible to select an invalid stack/component combination
  • Faster navigation - Only see applicable stacks, not your entire infrastructure
  • Better discoverability - Instantly see which stacks include a particular component

How It Works​

The completion system leverages Atmos's existing list stacks --component <name> functionality. When you provide a component argument, the --stack flag completion automatically filters the stack list based on which stacks define that component.

If no component is specified, all stacks are shown (preserving the original behavior).

Example​

Given this stack configuration:

# stacks/dev.yaml
components:
terraform:
vpc:
vars: {...}
myapp:
vars: {...}

# stacks/prod.yaml
components:
terraform:
vpc:
vars: {...}

Tab completion will now show:

  • atmos terraform plan vpc --stack <TAB> → dev and prod
  • atmos terraform plan myapp --stack <TAB> → dev only

This works across all Terraform commands: plan, apply, deploy, destroy, and more.

Scale Matters​

In organizations with large infrastructures, this becomes invaluable:

# Without filtering: overwhelming
$ atmos terraform plan vpc --stack <TAB>
dev-us-east-1 dev-us-west-2 dev-eu-west-1 dev-ap-south-1
staging-us-east-1 staging-us-west-2 staging-eu-west-1
prod-us-east-1 prod-us-west-2 prod-eu-west-1 prod-ap-south-1
sandbox-alice sandbox-bob sandbox-charlie
... (100+ more stacks)

# With filtering: manageable
$ atmos terraform plan vpc --stack <TAB>
dev-us-east-1 staging-us-east-1 prod-us-east-1
# Only the 3 stacks that actually have the vpc component