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?
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