Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested Terragrunt configuration with atlantis.yaml #279

Closed
stephencoe opened this issue Sep 17, 2018 · 5 comments
Closed

Nested Terragrunt configuration with atlantis.yaml #279

stephencoe opened this issue Sep 17, 2018 · 5 comments

Comments

@stephencoe
Copy link

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

live
├── 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 #244 but in the current implementation would the yaml expect each path to have its own project?

@stephencoe stephencoe changed the title Terragrunt configuration Nested Terragrunt configuration with atlantis.yaml Sep 17, 2018
@lkysow
Copy link
Member

lkysow commented Sep 17, 2018

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

@lkysow lkysow added the waiting-on-response Waiting for a response from the user label Sep 17, 2018
@stephencoe
Copy link
Author

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

@lkysow lkysow removed the waiting-on-response Waiting for a response from the user label Dec 3, 2018
@yuriydee
Copy link

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.

@lkysow
Copy link
Member

lkysow commented May 13, 2019

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

@yuriydee
Copy link

yuriydee commented May 13, 2019

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  

jamengual pushed a commit that referenced this issue Nov 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants