runatlantis / atlantis

Terraform Pull Request Automation
https://www.runatlantis.io
Other
7.68k stars 1.05k forks source link

Atlantis tries to plan template #3715

Open tekumara opened 1 year ago

tekumara commented 1 year ago

Community Note


Overview of the Issue

When using yaml anchors to create a template as per the docs, atlantis will try to plan the template and fails:

Ran Plan for 2 projects:

project: template dir: template workspace: default
project: awesome-project dir: infra/awesome-project workspace: default

1. project: template dir: template workspace: default
Plan Error

dir "template" does not exist

Reproduction Steps

  1. Create a template as per the docs
  2. Either
    • modify any of the files specified in autoplan -> when_modified, or
    • set --enable-regexp-cmd and then comment atlantis plan -p.*

Logs

Environment details

Repo atlantis.yaml file:

version: 3
parallel_plan: false
parallel_apply: false
projects:
  - &template
    name: template
    dir: template
    workflow: custom
    autoplan:
      enabled: true
      when_modified:
        - "./terraform/modules/**/*.tf"
        - "**/*.tf"
        - ".terraform.lock.hcl"

  - <<: *template
    name: awesome-project
    dir: ./infra/awesome-project

workflows:
  custom:
    plan:
    apply:

Additional Context

cShirley14 commented 7 months ago

Atlassian has an interesting approach with a definitons construct to avoid this sort of bug, would be cool to see a similar implementation in Atlantis: