Skip to content

autodiscover.ignore_paths not respected during apply #6325

@jholm117

Description

@jholm117

Description

autodiscover.ignore_paths correctly filters projects during atlantis plan, but atlantis apply (without -p) still discovers and attempts to apply projects in ignored paths.

Steps to Reproduce

  1. Have a repo with modules sourced from a git repository (e.g., source = "git@github.com:org/modules.git//module-name?ref=abc123")
  2. The module repo contains subdirectories with .tf files (e.g., test-deployment/main.tf) that are not actual deployable projects
  3. When Terraform downloads the module, the entire repo lands under .terraform/modules/<name>/, including those extra directories
  4. Configure atlantis.yaml with:
    autodiscover:
      mode: enabled
      ignore_paths:
        - ".terraform/**"
  5. Run atlantis plan — correctly discovers only the intended projects
  6. Run atlantis apply — discovers and attempts to apply the ignored paths, resulting in:
    no plan found at path "project/.terraform/modules/some_module/test-deployment" and workspace "default"–did you run plan?
    

Expected Behavior

atlantis apply should respect ignore_paths and only attempt to apply projects that were not filtered out.

Actual Behavior

atlantis apply picks up terraform roots inside ignored paths and fails with "no plan found" errors. The summary check (atlantis/apply) reports failures even though all real projects applied successfully.

Root Cause

The plan and apply code paths diverge in how they discover projects:

  • Plan path (buildAllCommandsByCfggetMergedProjectCfgs): calls isAutoDiscoverPathIgnored() to filter out ignored paths. Works correctly.
  • Apply path (buildAllProjectCommandsByPlan): uses PendingPlanFinder.Find() which scans the working directory for terraform roots via git ls-files. This path never checks ignore_paths.

The fix would be to add ignore_paths filtering inside buildAllProjectCommandsByPlan() after PendingPlanFinder.Find() returns results, similar to what getMergedProjectCfgs() does for plan.

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions