runatlantis / atlantis

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

Exclude directory without defining all directories in atlantis.yaml #859

Open jseiser opened 4 years ago

jseiser commented 4 years ago

I found an old github entry, that made this seem possible, but it appears its changed.

Is there a way to exclude a directory, that doesn't require listing every directory in atlantis.yml?

We are wanting non-engineers to be able to easily create their new environments via a pull request. So we will not know ahead of time, what 'projects' would exist at any given time.

Folder structure is like the below. _modules folder, example folder inside which is a almost 99% complete deployment, user just needs to create a folder at the root level, copy those files in and change the backed settings. I never need to plan or run on this folder.

Even the option to exclude this directory, but include all other directories based on some sort of regex would be great. like ignore module, but include any project starting with `deploy` etc.

 └── _modules
    └── app_tenant
        ├── credentials.tf
        ├── data.tf
        ├── examples
        │   ├── data.tf
        │   ├── main.tf
        │   └── setup.tf
        ├── iam.tf
        ├── kms-key.tf
        ├── mysql.tf
        ├── outputs.tf
        ├── s3.tf
        ├── templates
        │   ├── policy-kms.tpl
        │   ├── policy-s3.tpl
        │   └── policy-tenant-kms.tpl
        └── variables.tf
lkysow commented 4 years ago

Hi Justin, this is not possible right now. Every directory needs to be defined.

nitrocode commented 1 year ago

Currently the only way to do it would be to programmatically generate atlantis.yaml in a pre-workflow-run.

See projects like

You can also use a custom shell script to do this since the atlantis.yaml file is read on-the-fly.


Going forward, it would be handy to maybe have an atlantis.yaml interface like this

# proposal
autodiscover:
  enabled: true
  ignore:
    - "^_modules/.*"

# proposal: for all autodiscovered projects
project_defaults:
- workspace: default
  workflow: default
  autoplan:
    when_modified: ["*.tf", "../modules/**/*.tf"]
    enabled: true

# override autodiscovered projects matching the same
# combination of `dir`, `workspace`, `workflow`
projects:
- dir: terraform/nlb
  workspace: default
  workflow: default
  name: terraform/nlb
  autoplan:
    enabled: false

(all projects key ref)

This way we can set the defaults for ALL projects discovered and then override specific projects to ignore autoplanning.

In slack, @krrrr38 suggested an additional key called autodiscover to ignore specific paths

autodiscover:
  ignore_paths:
    - "^_modules$"

it would be good to study env0, spacelift, and terrateam to see what their interface is and how they solve this problem