terragrunt icon indicating copy to clipboard operation
terragrunt copied to clipboard

Unable to apply multiple modules at once.

Open RyanW8 opened this issue 8 months ago • 10 comments

Describe the bug

Our terragrunt file structure is the following, top level is the application name, 2nd level is account & 3rd is the region. E.g. Top Level = example_app 2nd Level = example_account 3rd Level = example_region Would look like

example_app/
  project.hcl
  terragrunt.hcl
  example_account/
    account.hcl
    example_region/
      region.hcl
      terragrunt.hcl

We define what the application terraform should look like at the application/top level like so

terraform {
 ...
}
locals {
  project_locals = read_terragrunt_config(find_in_parent_folders("project.hcl")).locals
  account_locals = read_terragrunt_config(find_in_parent_folders("account.hcl")).locals
  region_locals  = read_terragrunt_config("region.hcl").locals
}
...

child terragrunt.hcl files are located at app_name/account_name/region_name/terragrunt.hcl. And are simple terragrunt files that have an include block for the root terragrunt configuration (defined at the application/top level). In our root terragrunt configuration we define the above locals for all children, basic things like project/app level locals, account level & region level locals.

The issue is we are unable to use the run-all command to apply multiple accounts/regions at any given time as the terragrunt run-all <operation> command first validates/tries to run the root level terragrunt file which is invalid on it's own as the account & region level locals do not exists in that context.

Running plan/apply operation at the region level works correctly as it finds the child terragrunt.hcl

Expected behavior

Be able to run the run-all command from the top/application level

RyanW8 avatar Jun 03 '24 22:06 RyanW8