Terragrunt init-all functionality?

Hello Gruntworks!

Just wanted to see if what I’m doing is best practice and what you guys would recommend. Currently if we add a module (new AWS resource for instance) into our main.tf and then run terragrunt plan-all in our region folder which contains all our regions, we will get a bug that the module hasn’t been initialized. Currently I run a command like this to initialize all the newly installed modules:
find . -not -path ‘/.terragrunt-cache/’ -type f -name terragrunt.hcl -execdir terragrunt init ;

Would this be the best way to achieve init-all for terragrunt?

Hi ado120,

Unfortunately we don’t have an init-all command, as we expect init to run through the auto-init feature. Depending on how you are referencing the modules in terraform.source, the auto-init may not happen. Does your usage match one of the cases described in https://github.com/gruntwork-io/terragrunt/issues/936? If so, what you have using find is the best workaround available now.

Best regards,

Hello Yoshi,

Apologies for the long response, I appreciate you answering the two threads I had before going on vacation. I do indeed have a local parent Modules folder that I can in source with sub modules underneath that could change from time to time… From my understanding with the github link you sent me, the auto-init feature will not work. However could these be two possible workarounds?

  1. Deleting the local cache/workspace folder that gets downloaded before running terragrunt apply
  2. Moving my modules to private gitlab repo and sourcing them that way?

Yup both approaches would work, assuming that you are using immutable tags for the private gitlab repo. Otherwise, it may not init properly because terragrunt will assume that the source hasn’t changed.

Best regards,