Atlantis: Nested Terragrunt configuration with atlantis.yaml

Created on 17 Sep 2018  ยท  5Comments  ยท  Source: runatlantis/atlantis

We have a new setup of atlantis and I am trying to understand the yaml configuration required for terragrunt.
Given the example in the terragrunt-infrastructure-live-example

As far as I can see the yaml config looks like the expected structure is something similar to

โ”œโ”€โ”€ atlantis.yaml
โ”œโ”€โ”€ live
โ”‚   โ”œโ”€โ”€ prod
โ”‚   โ”‚   โ””โ”€โ”€ terraform.tfvars
โ”‚   โ””โ”€โ”€ staging
โ”‚       โ””โ”€โ”€ terraform.tfvars
โ””โ”€โ”€ modules
    โ””โ”€โ”€ null
        โ””โ”€โ”€ main.tf

but we have a more complex structure for multi account which follows something like

โ”œโ”€โ”€ dev
โ”‚ย ย  โ”œโ”€โ”€ account.tfvars
โ”‚ย ย  โ”œโ”€โ”€ application
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ terraform.tfvars
โ”‚ย ย  โ”œโ”€โ”€ network
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ vpc
โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ terraform.tfvars
โ”‚ย ย  โ”œโ”€โ”€ terraform.tfvars
โ”œโ”€โ”€ prod
โ”‚ย ย  โ”œโ”€โ”€ account.tfvars
โ”‚ย ย  โ”œโ”€โ”€ application
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ terraform.tfvars
โ”‚ย ย  โ”œโ”€โ”€ network
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ vpc
โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ terraform.tfvars
โ”‚ย ย  โ”œโ”€โ”€ terraform.tfvars
โ””โ”€โ”€ modules
    โ””โ”€โ”€ null
        โ””โ”€โ”€ main.tf

The use case would likely be solved with https://github.com/runatlantis/atlantis/issues/244 but in the current implementation would the yaml expect each path to have its own project?

All 5 comments

Yes for now you'll need every terragrunt project to be defined in the yaml:

version: 2
projects:
- dir: live/dev
  workflow: terragrunt
- dir: live/dev/application
  workflow: terragrunt
  ...
workflows:
  terragrunt:
    plan:
      steps:
      - run: terragrunt plan -no-color -out $PLANFILE
    apply:
      steps:
      - run: terragrunt apply -no-color $PLANFILE

thanks for confirming. I just read through #244 again and realise that it already answers this. Apologies for that!

Sorry for opening the issue again but I was wondering if there are any plans to enable wildcard support for terragrunt ?

Just like OP we have a whole repository of terraform.tfvars files in their own folders and doing terragrunt plan-all as a work around isnt ideal and takes too long.

Ideally I'd like something like:

projects:
- dir: account-number/*
  workflow: terragrunt
  autoplan:
    when_modified: ["account-number/**/*"]

Otherwise every time we add a new directory, we'd have to edit the atlantis.yaml file and add it there as well, and it gets messy when we have over 30 folders.

Would setting a new default workflow server-side work? https://www.runatlantis.io/docs/server-side-repo-config.html#change-the-default-atlantis-workflow

Yeah setting terragrunt as default workflow on the server side helped with the automatic plans but Im still having issues with the plan not running in the correct directory. Also I noticed that it will work properly and use the default terragrunt workflow every time I do a commit or PR, but when I comment atlantis plan -d my_path it still defaults to using regular terraform for the plan instead of the default terragrunt workflow. Not sure if thats a bug or if there is another place I need to edit the default ?

As for the my original issue I have,

version: 3
projects:
- name: Sandbox
  dir: 1234567890-sandbox/
  autoplan:
    when_modified: ["./**/**/*.tfvars"]
  workflow: default

It triggers a plan but the problem is it only run the terragrunt plan for the 1234567890-sandbox/, while the file edited was actually 1234567890-sandbox/us-east-1/vpc/terraform.tfvars. Is there any way to allow Atlantis to plan only the files that get edited in the project directory?

My server side config right now is:

repos:                                                                                                                                                                    
- id: /.*/                                                                                                                                                                
  apply_requirements: [approved]                                                                                                                                          
  allowed_overrides: [workflow]                                                                                                                                           
  allow_custom_workflows: true                                                                                                                                            

workflows:                                                                                                                                                                                                                                                                                   
  default:                                                                                                                                                                
    plan:                                                                                                                                                                 
      steps:                                                                                                                                                              
      - run: terragrunt plan -no-color -out $PLANFILE                                                                                                                     
    apply:                                                                                                                                                                
      steps:                                                                                                                                                              
      - run: terragrunt apply -no-color $PLANFILE  
Was this page helpful?
0 / 5 - 0 ratings

Related issues

richstokes picture richstokes  ยท  3Comments

natalysheinin picture natalysheinin  ยท  3Comments

cket picture cket  ยท  5Comments

atlantisbot picture atlantisbot  ยท  4Comments

kipkoan picture kipkoan  ยท  3Comments