runatlantis / atlantis

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

[Possible regresion] Autoplan ignores when_modified in a per-repo config #3796

Open szaffarano opened 11 months ago

szaffarano commented 11 months ago

Community Note


Overview of the Issue

We were able to reproduce this issue running v0.24.3, v0.24.4 and v0.25.0.

We have a project structure similar to

test
β”œβ”€β”€ atlantis.yaml
└── infra
    β”œβ”€β”€ modules
    β”‚Β Β  └── module-one
    β”œβ”€β”€ project-one
    └── project-two

and our atlantis.yaml file looks like

version: 3
projects:
  - &template
    name: template
    dir: template
    workflow: default
    autoplan:
      enabled: true
      when_modified:
        - "**/*.tf"
        - ".terraform.lock.hcl"

  - <<: *template
    name: infra/project-one
    dir: ./infra/project-one
    workflow: project-one

  - <<: *template
    name: infra/project-two
    dir: ./infra/project-two
    workflow: project-two

Atlantis is running with the following environment variables

ATLANTIS_AUTOPLAN_MODULES=true
ATLANTIS_AUTOPLAN_FILE_LIST=**/*.tf

Everything works as expected, i.e.,

  1. We change project-one/main.tf and atlantis runs the plan just for project-one.
  2. If we update modules/module-one/some-file.tf and module-one is used only for project-two, then Atlantis runs the plan only for project-two.
  3. But if we change, for example, project-one/README.md Atlantis also runs the plan for project-one although the updated file doesn't match with ATLANTIS_AUTOPLAN_FILE_LIST.

If we downgrade to v0.23.3, the previous version after this fix, then use case 3) works (i.e., Atlantis doesn't run anything wen we change files not matching ATLANTIS_AUTOPLAN_FILE_LIST), but Autoplan Modules (use case 2) stops working. So, I'd say it's a regression introduced by the linked PR.

Reproduction Steps

Just follow the two use cases I listed above.

Logs

Environment details

Additional Context

jamengual commented 11 months ago

@jukie do you think this could be a bug?