Wrap Up
Congratulations on making it through the Terralith to Terragrunt guide!
You’ve successfully navigated the entire journey from a cumbersome Terralith to a clean, scalable, and maintainable IaC setup managed by Terragrunt. This process mirrors the real-world challenges many teams face as their infrastructure grows, and the skills you’ve developed are invaluable for managing IaC effectively at any scale.
Along the way, you’ve practiced and mastered critical techniques that will serve you well on your path to IaC mastery. You now have hands-on experience with:
- Advanced State Manipulation: Safely refactoring your infrastructure’s state without destroying and recreating critical resources. You’ve used OpenTofu’s
moved
andremoved
blocks andstate pull
andstate push
commands to migrate state between different file system layouts and backend configurations. - Modular Infrastructure Design: Breaking down a monolithic configuration into smaller, reusable modules with clear, encapsulated APIs. You learned to structure your project with a
catalog
of components that can be consumed by yourlive
infrastructure. - Boilerplate Reduction with Terragrunt: Eliminating repetitive code by using
terragrunt.hcl
to generate provider and backend configurations, define module sources, and pass inputs dynamically using functions likeget_repo_root()
andpath_relative_to_include()
. - Dependency Management: Orchestrating complex deployments across multiple, isolated state files. You learned to use Terragrunt’s
dependency
blocks to pass outputs from one component as inputs to another, and how to usemock_outputs
to enable successful planning even before dependencies have been applied. - Dynamic Stack Generation: Transitioning from manually managing individual
terragrunt.hcl
files to defining entire environments on-demand with a singleterragrunt.stack.hcl
file, making your infrastructure definitions radically simpler and easier to maintain.
If you’d like to continue practicing on your own, consider how you might continue experimenting with this configuration.
-
Nested Stacks: What if you wanted to manage both the
dev
andprod
environments from a single, top-level file using the Environment-based Stacks pattern? Think about how you would refactor your current setup to achieve this. Would you need to perform more state manipulation? If so, which techniques from this guide would you leverage to accomplish it safely? -
Integrating Terragrunt Into Your Build System: In this guide, the artifact that’s deployed to Lambda is manually packaged by you before provisioning any infrastructure. Terragrunt has special tooling in hooks to automate manual tasks like this for you on-demand as you interact with your infrastructure. How would you integrate that into the configurations you’ve built so far?
-
Testing Our IaC: If you were to use this infrastructure in production, you might want the underlying patterns (and perhaps the live infrastructure) tested automatically, rather than just applying the IaC and manually verifying that it is working correctly. How would you go about doing that?
-
Automating Plan Assessments: Throughout this guide, you engaged in careful manual evaluation of plans, and it was hinted early on that tools like OPA provide a way to automatically assess the risk of plans. How would you integrate them into Terragrunt?
This was a simple example, but if you’re struggling with a Terralith, your use-case is almost definitely more complex! Gruntwork offers support for assisting customers transition out of Terraliths into maintainable, best practices IaC codebases.
Send an email to sales@gruntwork.io for Terragrunt Enterprise Support for more information.