#terragrunt (2019-09)

terragrunt

Terragrunt discussions

Archive: https://archive.sweetops.com/terragrunt/

2019-09-06

antonbabenko avatar
antonbabenko

Hi guys! @loren Have you found a solution to this https://github.com/gruntwork-io/terragrunt/issues/785 ? I wonder how people are solving odd (“new”) behavior of init hooks?

postpone check for configured backend after init hook is executed · Issue #785 · gruntwork-io/terragrunt

Change-Request: Postpone check for checkTerraformCodeDefinesBackend() after before_hooks are run. I guess it makes sense to run a before_hook before deciding how to actually execute theterraform co…

loren avatar

solve? no… workaround, yes… it’s not pretty

loren avatar

basically just gitignoring the copied file

loren avatar

in terragrunt.hcl

  after_hook "provider" {
    commands = ["init-from-module"]
    execute  = ["cp", "${get_terragrunt_dir()}/../../provider.tf", "."]
  }
loren avatar

in .gitignore

# Terragrunt files copied by hooks
dev/**/provider.tf
loren avatar

i tried your workaround of having a hook delete the file, but turns out we actually need it there because terragrunt tracks the files it copies from the terragrunt dir to its cache working dir, and purges anything from the cache working dir that it didn’t copy

antonbabenko avatar
antonbabenko

Great, I ~solved~orkaround it exactly as you said. I am not sure there will be a proper fix in the near future. It starts to look a big ugly here and there with terragrunt…

loren avatar

yeah, i think we need the workflow to be part of terragrunt proper, rather than implemented with hooks

loren avatar

it’s not something the gruntwork folks do, so they just don’t see it as a real use case at the moment

1
antonbabenko avatar
antonbabenko

As another not elegant hack I can run terragrunt plan --terragrunt-source-update to get source reinitiated every time, then I can have after_hook which will remove the file.

loren avatar

Right, yeah, that also works, but is slow

1
Adrian avatar

add some dep between modules and its very slow

2019-09-10

Mariano Godoy avatar
Mariano Godoy

Hi guys!, does anyone know how to solve dependencies between modules without having to run a terragrunt plan-all from the root directory? This is our current directory structure

root
├── dynamodb
│   ├── TableOneDir
│   │   └── terragrunt.hcl
│   ├── TableTwoDir
│   │   └── terragrunt.hcl
├── lambda
│   ├── LambdaOneDir
│   │   └── terragrunt.hcl
│   ├── LambdaTwoDir
│   │   └── terragrunt.hcl
├── secrets
│   └── terragrunt.hcl
├── sns
│   └── terragrunt.hcl
└── terragrunt.hcl

We need to run plan only in the LambdaOne directory and auto resolve a dependecy of a TableOneDir existing.

Also this are out hcl examples

terraform {
  source = "git::[email protected]:Company/core-of-sources.git//lambda/LambdaOneDir?ref=branch-one"
}

# Include all settings from the root terragrunt.hcl file
include {
  path = find_in_parent_folders()
}

# Dependencies
dependencies {
  paths = ["../../dynamodb/TableOneDir"]
}
loren avatar

there are some very new features of terragrunt to support this… make sure you are using the latest version and then read these sections in the readme:

https://github.com/gruntwork-io/terragrunt#passing-outputs-between-modules

https://github.com/gruntwork-io/terragrunt#unapplied-dependency-and-mock-outputs

maarten avatar
maarten

@cytopia

maarten avatar
maarten
gruntwork-io/terragrunt

Terragrunt is a thin wrapper for Terraform that provides extra tools for working with multiple Terraform modules. - gruntwork-io/terragrunt

1
Gustavo Adrián Crespi avatar
Gustavo Adrián Crespi

Nice feature! But still we have a problem we don’t really know how to solve. Say we modify our implementation of the LambdaOne module and also some configuration on dynamo’s TableOne we need for the same feature, then we would like to run a plan for those changes. We would like only to run terragrunt plan inside of the LambdaOne folder and doing so we expect it automatically to cascade the plan to its dependencies (in this case TableOne) is that possible? We understand that running terragrunt plan on the root folder would solve this problem but since we are using Atlantis doing so would automatically lock all the directory and won’t allow us to work concurrently with other team mates.

loren avatar

no, not using plan. but plan-all should do exactly that

loren avatar

oh, but right, that will lock all the other directories, hrm…

loren avatar

maybe open a feature request for a new flag --terragrunt-process-dependencies or somesuch

Gustavo Adrián Crespi avatar
Gustavo Adrián Crespi

You are right! plan-all is what we need to use, but I’ve found there is a problem with the non-interactive mode and that is that while setting this option on, there is no way to turn on the option to also apply the command on the dependencies of the module. I’ve spotted the Issue here: https://github.com/gruntwork-io/terragrunt/issues/860

Setting to apply external dependencies in Non-interactive mode · Issue #860 · gruntwork-io/terragrunt

Today's behaviour defaults to not applying external dependencies in non-interactive mode as we can see in these lines of code. I would like to have some configuration (for example a cli option)…

AgustínGonzalezNicolini avatar
AgustínGonzalezNicolini

@Gustavo Adrián Crespi we may also consider opening a PR and colaborating

AgustínGonzalezNicolini avatar
AgustínGonzalezNicolini

2019-09-11

2019-09-16

Sharanya avatar
Sharanya

quick question

  • terragrunt –version /var/lib/jenkins/workspace/gc-vitr-landing-page_master@tmp/durable-dfb884a1/script.sh: line 1: terragrunt: command not found [Pipeline] } —- Have this error in my Jenkins build…. have any one come across this ever ?
aaratn avatar

@Sharanya is terragrunt in your path ?

Sharanya avatar
Sharanya

yes

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

in the PATH or is installed

aaratn avatar

+1

Sharanya avatar
Sharanya

i dont think terragrunt in installed on the server

aaratn avatar

You will need to install it

    keyboard_arrow_up