You asked, we listened. This has become the most requested feature we’ve ever had.
That’s right, we’re finally launching the Terragrunt run-all functionality.
We’ve had Terragrunt support since December 2020, with that initial release supporting running a specific folder at a time. Terragrunt, however, has a neat capability to execute multiple Terraform modules at once, with the bonus of being able to define module dependencies too.
With this new release, it’s now possible to run parallel folders of Terraform modules. Admins can configure the template to `run-all` modules, with users able to toggle the functionality when they run the template.
What is Terragrunt? Why use Terragrunt run-all?
Terragrunt is an excellent solution for keeping your infrastructure configurations DRY (Don’t Repeat Yourself), managing multiple Terraform modules, and managing remote state. It allows us to define Terraform code only once, irrespective of how many environments we’re running.
By using Terragrunt, we’re able to eliminate duplicate backend code. Instead, we can manage Terraform state once in the root directory, and it’s inherited by all child modules.
Finally, Terragrunt allows us to execute Terraform commands on multiple modules. We only need to run one command for all modules, instead of executing for each independent module.
This is the convenience of Terragrunt “run-all”.
With “run-all”, not only do we run the Terraform command on multiple modules, it creates a dependency graph between those modules, and allows the passing of outputs as inputs to different modules.
How to use Terragrunt run-all in env0
How to use Terragrunt in env0 using a template
Here’s how to enable “run-all” in the UI when creating your Terragrunt template
When creating a new template in env0, first select the Terragrunt template type. Next, expand the “Advanced” options and click the check box to “Execute run-all commands on multiple modules”.
How to execute Terragrunt run-all in env0 without a template
To execute Terragrunt run-all without creating a new template in env0, select “Create new environment” from within your project.
Choose the VCS option to “Create an environment from a VCS integration.” This allows us to create a new environment directly from your source code repo.
Select the Terragrunt template type. Expand the “Advanced” options. Click the checkbox to “Execute run-all commands on multiple modules”
In Step 2, you’ll choose your VCS, select the repository, branch, and folder which contains your Terragrunt files.
In Step 3, define the variables.
Finally, name your environment, and select your desired env0 features, like Drift Detection or Plan on Pull Requests.
Here in the deployment logs we can see the results of the `run-all plan`. Expanding to dive deeper will show whether or not the configuration is valid, as well as any changes that were committed in a human readable format for ease of troubleshooting. Depending on whether we prefer to apply before or after merge, we can also insert an approval step to satisfy governance and compliance requirements.
After our changes have been approved, we can view the logs for `run-all apply`
Since Terragrunt run-all environments will include output from each Terraform module, we’ll list the outputs in the UI by presenting them as a separate group for each module folder.
Terragrunt and env0 - Manage your infrastructure at scale
Rejoice all ye Terragrunt users, for the day has come that Terragrunt run-all has come to env0! This allows you to execute Terraform commands on multiple modules, with the added ability to define dependencies. This is perfect for creating more complex Terraform environments with multiple modules, setting up the dependencies between them, and for keeping your Terraform code DRY!
By using Terragrunt with env0, you’ll also get approval flows, plan on pull request, continuous deployment, ephemeral environments, scheduling and drift detection. This provides the robust functionality needed to automate, manage and govern Terragrunt at scale.