runatlantis / atlantis

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

Atlantis not running plans on projects with depends_on in atlantis.yaml #4745

Open knjoroge opened 1 month ago

knjoroge commented 1 month ago

Community Note


Overview of the Issue

Our infrastructure is based off of https://github.com/terraform-google-modules/terraform-example-foundation We build our infrastructure in layers 0,1,2,3,4,5...

When we make a terraform change to a lower layer project, we want atlantis to run a plan on the upper layer projects that depend on the lower layer project.

When I make a change to layer 3, I expect atlantis to run a plan on all projects in upper layers that depends_on layer 3. For example, I'm only modifying a project in layer 3 and the project in layer 5 depends_on layer 3 but a plan is not being triggered.

Why doesn't depends_on not trigger a plan on projects in the upper layer projects? Is this expected or is this a bug?

Reproduction Steps

Repo atlantis.yaml file:

#project I modify

`- name: gcp-3-networks
  dir: infrastructure-gcp/3-networks/environments/common
  autoplan:
    when_modified:
    - '*.tf'
    - ../../modules/**/*.tf
    - '**/*tfvars'
  depends_on:
  - gcp-0-bootstrap
  - gcp-1-org
  workspace: gcp-3-networks
  workflow: default
  terraform_version: v1.6.3`
# An upper layer project that depends_on gcp-3-networks project but a plan is not being triggered here.

- name: gcp-5-infra-ci
  dir: infrastructure-gcp/5-infra-ci/environments/common
  autoplan:
    when_modified:
    - '*.tf'
    - ../../modules/**/*.tf
    - '**/*tfvars'
  depends_on:
  - gcp-3-networks
  workspace: gcp-5-3-infra-ci
  workflow: default
  terraform_version: v1.6.3

Environment details

Atlantis server-side config file:

repos:
- id: github.com/xxxx/monorepo
  apply_requirements: [mergeable]
  allowed_overrides: [workflow]
the-nando commented 1 month ago

@knjoroge depends_on is used to enforce only the order of execution of plans and applies: https://www.runatlantis.io/docs/repo-level-atlantis-yaml#order-of-planning-applying it doesn't alter the way auto-planning works for a given project or trigger plans on its own.

gustaff-weldon commented 1 month ago

@the-nando That is a great shame as it could be much better used. When workspace A depends_on B and B is changed, it feels natural to trigger autoplan for A