runatlantis / atlantis

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

Atlantis doesn't respect child directories in project #2597

Open gartemiev opened 1 year ago

gartemiev commented 1 year ago

I have a project in my repo which contains sub folders in addition. However After specifying that project on repocinfig level - Atlantis doesn't see any subprojects there:

running "/usr/local/bin/terraform plan -input=false -refresh -out \"/home/atlantis/.atlantis/repos/example/dev-infra/121/default/eu-central-1/infrastructure/infrastructure-default.tfplan\"" in "/home/atlantis/.atlantis/repos/example/dev-infra/121/default/eu-central-1/infrastructure": exit status 1
╷
│ Error: No configuration files
│ 
│ Plan requires configuration to be present. Planning without a configuration
│ would mark everything for destruction, which is normally not what is
│ desired. If you would like to destroy everything, run plan with the
│ -destroy option. Otherwise, create a Terraform configuration file (.tf
│ file) and try again.

Server side config:

repos:
  - id: bitbucket.org/example/dev-infra
    allow_custom_workflows: true
    allowed_overrides: [apply_requirements, workflow]

Repo config:

---
version: 3
projects:
- name: infrastructure
  dir: ./eu-central-1/infrastructure
  autoplan:
    when_modified:
      - "**/*.tf"
    enabled: true
  workflow: default
nitrocode commented 1 year ago

I've run into this exact issue. For auto planning, you can define zero projects or define all of them. You cannot define some and still have auto planning work for undefined projects

https://github.com/runatlantis/atlantis/blob/8b20bebf167c92e3f4ceffba32739187b79115ec/server/events/project_command_builder.go#L272-L274 https://github.com/runatlantis/atlantis/blob/8b20bebf167c92e3f4ceffba32739187b79115ec/server/events/project_command_builder.go#L304-L306

This other issue may be related

https://github.com/runatlantis/atlantis/issues/2593