Atlantis: Support for Terragrunt

Created on 10 Jul 2018  ยท  8Comments  ยท  Source: runatlantis/atlantis

Hi,
I have looked through the documentation and also through the source code and it appears it is not possible to use Terragrunt. Is this correct?
If so, will there be any plans to implement support for Terragrunt? If not, is there particular approach you recommend for implementing Terragrunt compatibility into this project?

Thanks

Most helpful comment

Sure, here an example of my atlantis.yaml :

version: 2
projects:
- name: project1
  dir: path/project1
  workflow: terragrunt
  workspace: default
  autoplan:
    when_modified: ["*.tfvars"]
    enabled: true
  apply_requirements: [approved]
workflows:
  terragrunt:
    plan:
      steps:
      - run: terragrunt plan --no-color -out $PLANFILE | terrahelp mask
    apply:
      steps:
      - run: terragrunt apply --no-color $PLANFILE | terrahelp mask

And I use terrahelp to mask the sensitive data on output.

All 8 comments

Hi Bonamy,
I just tried it using the custom commands that Atlantis supports and it seems to work.

I have a repo structure like:

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

Where I'm using the local modules/null in my terraform.tfvars:

terragrunt = {
  terraform {
    source = "../../modules/null"
  }
}

And the contents of atlantis.yaml were:

version: 2
projects:
- dir: live/staging
  workflow: terragrunt
  autoplan:
    when_modified: ["*.tf*", "../../modules/null/*.tf"]
- dir: live/prod
  workflow: terragrunt
  autoplan:
    when_modified: ["*.tf*", "../../modules/null/*.tf"]
workflows:
  terragrunt:
    plan:
      steps:
      - run: TF_CLI_ARGS='-no-color' terragrunt plan -out $PLANFILE
    apply:
      steps:
      - run: TF_CLI_ARGS='-no-color' terragrunt apply $PLANFILE

When the pull request was opened, it run terragrunt plan successfully and to apply, I ran atlantis apply -d live/staging and atlantis apply -d live/prod.

Let me know if that works?

Oh, you'll have to use the current master branch of Atlantis because the latest release doesn't have the PLANFILE environment variable available yet.

FYI this is available in the latest release (0.4.1) now.

Hi,
It's works well on my side. Just a thing that I had to use the --no-color in terragrunt cli and not in exported env-var due to a bug in terraform : https://github.com/hashicorp/terraform/issues/14847

Oh interesting. Can you give me an example of your config then so I can document this?

Sure, here an example of my atlantis.yaml :

version: 2
projects:
- name: project1
  dir: path/project1
  workflow: terragrunt
  workspace: default
  autoplan:
    when_modified: ["*.tfvars"]
    enabled: true
  apply_requirements: [approved]
workflows:
  terragrunt:
    plan:
      steps:
      - run: terragrunt plan --no-color -out $PLANFILE | terrahelp mask
    apply:
      steps:
      - run: terragrunt apply --no-color $PLANFILE | terrahelp mask

And I use terrahelp to mask the sensitive data on output.

Terragrunt is working in the latest release.

Was this page helpful?
0 / 5 - 0 ratings