transcend-io / terragrunt-atlantis-config

Generate Atlantis config for Terragrunt projects.
https://transcend.io/blog/why-we-use-terragrunt
MIT License
613 stars 96 forks source link

read_terragrunt_config fails if referenced file has dependencies #354

Open mm-nv2020 opened 3 days ago

mm-nv2020 commented 3 days ago

Bug report

atlantis.yaml cannot be generated if the child terragrunt.hcl uses read_terragrunt_config function on a file that contains dependencies.

To Reproduce

Summarize how to reproduce the behavior. For example:

  1. clone the example repo
  2. Run the command terragrunt-atlantis-config generate --output atlantis.yaml --filter child/001
  3. if skip_outputs is set to true on dependency caller, there is no error

Expected behavior

No error. I expected the generated Atlantis config to look like:

automerge: false
parallel_apply: true
parallel_plan: true
projects:
- autoplan:
    enabled: false
    when_modified:
    - '*.hcl'
    - '*.tf*'
    - ../../terragrunt.hcl
  dir: child/001
version: 3

Actual behavior

INFO[0000] Could not find an old config file. Starting from scratch 
ERRO[0000] Error: Error in function call

ERRO[0000]   on /atlantis_read_terragrunt_config_dependency/child/001/terragrunt.hcl line 6, in locals: 
ERRO[0000]    6:   common = read_terragrunt_config(find_in_parent_folders("common-child.hcl")) 
ERRO[0000]                                              
ERRO[0000] Call to function "read_terragrunt_config" failed: The RunTerragrunt option has not been set on this TerragruntOptions object.

ERRO[0000] Encountered error while evaluating locals in file /atlantis_read_terragrunt_config_dependency/child/001/terragrunt.hcl 
Error: /atlantis_read_terragrunt_config_dependency/child/001/terragrunt.hcl:6,12-35: Error in function call; Call to function "read_terragrunt_config" failed: The RunTerragrunt option has not been set on this TerragruntOptions object.

Relevant Terragrunt files a link to a repository with the smallest set of code needed to reproduce the issue: https://github.com/kbcz1989/atlantis_read_terragrunt_config_dependency/tree/master

cgarcia-l commented 1 day ago

Hi, I'm currently experiencing the same issue. Unfortunately, I haven't found a useful solution so far. I'll keep looking and update here if I come across anything that works.

Sancretor commented 8 hours ago

Hi ! I just got the same issue and will try to do some debug in the coming weeks.