Sometimes specifying every project in digger.yml by hand is suboptimal, especially with a large number of small statefiles. In this scenario you can use the generate_projects directive in digger.yml. Digger will then traverse the directory according to include_patters and exclude_patterns provided and dynamically generate the list of projects

generate_projects:
  include: "projects/dev/*"
  exclude: "projects/dev/test3"

Blocks syntax

You can also specify multiple include / exclude entries like this:

generate_projects:
  blocks:
    - include: "environments/core/**"
      workflow: default_work_flow
    - include: "environments/cicd/**"
      workflow: default_work_flow
    - include: "environments/dev/**"
      workflow: default_work_flow
    - include: "environments/qa/**"
      workflow: default_work_flow

Demo repo

Traversing nested directories

You can optionally set the top-level argument traverse_to_nested_projects to generate a project for all sub-directories:

traverse_to_nested_projects: true
generate_projects:
  blocks:
    - include: "environments/core/**"

This will create a project for all sub-directories under environments/core. If set to false, only the first directory with a .tf file will be evaluated.

Blocks syntax with Terragrunt

You can use blocks generation with terragrunt as well. In order to acheive this all you need to do is specify terragrunt: true for each block. Normally you would only have one terragrunt structure and so you will have one block entry. However you may be also interested to specify different structure and different parameters for different folders. For example, you may have a dev, staging and prod account heirarchy and therefore you would specify the blocks in that way. Alternatively maybe you have different providers and you would like to specify those different providers as well. Note that for very large terragrunt monorepos segragating by blocks will lead to improved performance since it will not unnecessarily traverse an entire tree if no files have been changed within it.

generate_projects
    blocks:
      - block_name: dev
        terragrunt: true
        root_dir: "dev/"
        workflow: default
        workflow_file: digger_workflow_dev.yml
      - block_name: staging
        terragrunt: true
        root_dir: "staging/"
        workflow: default
        workflow_file: digger_workflow_staging.yml