diggerhq / digger

Digger is an open source IaC orchestration tool. Digger allows you to run IaC in your existing CI pipeline ⚡️
https://digger.dev
Apache License 2.0
4.3k stars 578 forks source link

make modules-related include patterns dynamic #393

Open fleroux514 opened 1 year ago

fleroux514 commented 1 year ago

We are using a mono-repo, where different projects are reusing various modules specified under the ./modules directory which contains 10+ modules.

In each project, I currently need to do a manual verification of which modules are being used, in order to specify them statically using the include_patterns project config. And if we eventually start using a new Terraform module in a project, there is a good chance we might forget to update digger.yml accordingly while doing so. So the current workflow is very error prone.

Digger should dynamically detect module directories without the need to specify them using include_patterns.

In the following code snippet, Digger could scan the code and detect that the "vpn-ha" module is being used in this case.

./envs/dev/main.tf

module "shared_base_vpn" {
  source = "../../modules/vpn-ha"

  project_id           = local.base_project_id
  default_region1      = var.default_region1
  default_region2      = var.default_region2
...
}
ZIJ commented 1 year ago

Thanks for reporting it @fleroux514 ! Indeed, modules_dir making sense Tagging @Spartakovic if you have any input on the way this should work?

Spartakovic commented 1 year ago

there is probably no need to have module_dir, since we are going to parse tf files? otherwise seems like a great idea, i wonder if any other tool is doing that

fleroux514 commented 1 year ago

@Spartakovic you are right :) no need to specify if digger is going to parse it anyways...

ZIJ commented 1 year ago

The last comment suggests the issue can be closed. Labeling as such - if someone disagrees please indicate in the next few days

Spartakovic commented 1 year ago

not exactly, wanted functionality is still missing, it's just that solution suggested in the title is not the one preferred

fleroux514 commented 1 year ago

Correct, just updated the title/description for this feature request.

luong-komorebi commented 6 months ago

bumping this issue up because this is still valid. Now with generate_projects and include/exclude pattern, part of this problem has been solved already. As an extension, I wish there is a way to tell digger to update all projects that rely on a module (referenced by relative path), plan and execute when there are changes inside the module