atlantis icon indicating copy to clipboard operation
atlantis copied to clipboard

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

Open knjoroge opened this issue 1 year ago • 2 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

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 version: 1.6.3
  • Deployment method: Terraform GCP Atlantis module https://github.com/runatlantis/terraform-gce-atlantis/tree/main

Atlantis server-side config file:

repos:
- id: github.com/xxxx/monorepo
  apply_requirements: [mergeable]
  allowed_overrides: [workflow]

knjoroge avatar Jul 11 '24 10:07 knjoroge

@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.

the-nando avatar Jul 15 '24 09:07 the-nando

@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

gustaff-weldon avatar Jul 17 '24 15:07 gustaff-weldon

I’m on the same page with @knjoroge. The current behavior of depends_on feels very unintuitive. I would also expect a dependent project to be planned when plans are triggered in the child project.

It’s very common practice to split large Terraform state into smaller substates that can be dependent on each other. In scenarios where the dependency cannot be solved with data sources and one has to pull outputs from the other state, this would require a refresh of the parent state. Currently, this cannot be solved easily with Atlantis, only with complex when_modified patterns.

FloSchick avatar Feb 06 '25 07:02 FloSchick