{"id":518148,"date":"2024-11-18T16:16:19","date_gmt":"2024-11-18T15:16:19","guid":{"rendered":"https:\/\/www.devoteam.com\/expert-view\/terragrunt-keep-terraform-dry\/"},"modified":"2025-05-07T12:18:53","modified_gmt":"2025-05-07T10:18:53","slug":"terragrunt-keep-terraform-dry","status":"publish","type":"expert-view","link":"https:\/\/devoteam.info\/en-nl\/expert-view\/terragrunt-keep-terraform-dry\/","title":{"rendered":"Terragrunt: Keep Terraform DRY With A Clean and Efficient Code"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In this article, we will explore Terragrunt, a popular tool that promotes DRY (Don&#8217;t Repeat Yourself) practices and helps you use Terraform more effectively. DRY practices <span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\"><strong>aim to reduce repetitive patterns and ensure<\/strong><\/span><strong> that every piece of knowledge in your system has a single, unambiguous representation<\/strong>. We will also see how to use Terragrunt to set up resources on Google Cloud (GCP).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By walking through a practical example, you will learn how to streamline your Terraform configurations, improve code maintainability, and efficiently manage your cloud infrastructure in<a href=\"https:\/\/devoteam.info\/en-nl\/join-us\/google-cloud-4\/\"> Google Cloud.<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-terragrunt-make-the-most-of-terraform\">Terragrunt: Make the most of Terraform<\/h2>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"963\" src=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Capture-decran-2024-11-07-a-09.09.14-1024x963.jpg\" alt=\"\" class=\"wp-image-84289\" style=\"width:925px;height:auto\" srcset=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Capture-decran-2024-11-07-a-09.09.14-1024x963.jpg 1024w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Capture-decran-2024-11-07-a-09.09.14-300x282.jpg 300w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Capture-decran-2024-11-07-a-09.09.14-768x722.jpg 768w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Capture-decran-2024-11-07-a-09.09.14.jpg 1404w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Before we start, make sure you have a basic understanding of Terraform.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Terraform is an Infrastructure as Code (IAC) tool that provisions and manages infrastructure (resources) in any cloud or data centre. It\u2019s a powerful tool for IAC, but it can encounter many challenges as projects grow. For example, Terraform configurations can become repetitive and duplicated, especially when handling multiple environments and components. Which can lead to maintenance difficulties.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Additionally, Terraform modules can depend on each other, complicating management and increasing the risk of errors due to manual oversight.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Managing a remote state can also become complex and challenging in large projects, especially when working with multiple environments and different teams. Similarly, provisioning and managing resources across multiple environments and reusing the same components can be tedious and difficult.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Terragrunt offers solutions to all of these challenges.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-terragrunt-s-core-benefits\"><strong>Terragrunt&#8217;s Core Benefits<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-eliminate-repetition-with-terragrunt\"><strong>Eliminate Repetition with Terragrunt<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Abstractions or the &#8220;Don&#8217;t Repeat Yourself&#8221; (DRY) principle is a well-known software engineering pattern that aims to reduce duplicated code. This helps avoid managing extra configurations and simplifies system changes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Terragrunt allows you to share configurations across multiple Terraform modules or environments by defining, for example, the backend configurations, provider configurations, and variables at the root level. This way, all child modules can inherit these settings, eliminating repetition and promoting reusability.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-effortless-state-management-with-terragrunt\"><strong>Effortless State Management with Terragrunt<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Terragrunt stores state files remotely, automatically creating and enabling locking resources (bucket) automatically to manage states. This helps avoid manual errors, state overwrites, and shares states across teams. As a result, you ensure that you are using the correct state configuration without any manual configuration of your modules.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-simplify-dependencies-between-modules\"><strong>Simplify Dependencies Between Modules<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Usually, terraform modules depend on each other. For example, a database or computer instance may depend on the network, requiring you to manage the order in which modules are deployed. Terragrunt allows you to manage dependencies between modules explicitly, ensuring resources are provisioned in the correct order. Additionally, the outputs of modules can be passed to others, streamlining the process.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-terragrunt-manage-multiple-environments-with-ease\"><strong>Terragrunt: Manage Multiple Environments with Ease<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Managing multiple environments with Terraform requires additional configuration and management through workspaces and variables. This can be tedious and error-prone. Terragrunt simplifies this process by allowing you to define separate configuration files for each environment, reducing code duplication and minimising errors.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-streamline-your-terraform-workflow\"><strong>Streamline Your Terraform Workflow<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In large projects with many teams, modules, and resources, Terraform can make it challenging to manage the workflow (init, plan, apply, etc.) across different environments, teams, and modules.&nbsp; Terragrunt simplifies this by automatically running Terraform commands in the correct order across modules, eliminating the need for manual execution and keeping files organised.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-practical-terragrunt-use-cases-deploying-on-google-cloud\"><strong>Practical Terragrunt Use Cases: Deploying on Google Cloud<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This example is not intended for production use; it demonstrates key features of Terragrunt. It helps keep your terraform code DRY, remote state configuration DRY, and Terragrunt architecture DRY.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This project deploys (a GCE, a MySQL database, an Instance Template, and a VPC) in three environments (dev, stage, and prod)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This project utilises public Terraform modules for GCP and is inspired by the official Terragrunt documentation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-source-code\">Source code<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"243\" src=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GitHub-Moncif1hello_terragrunt-1024x243.png\" alt=\"\" class=\"wp-image-84327\" style=\"width:679px;height:auto\" srcset=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GitHub-Moncif1hello_terragrunt-1024x243.png 1024w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GitHub-Moncif1hello_terragrunt-300x71.png 300w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GitHub-Moncif1hello_terragrunt-768x182.png 768w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GitHub-Moncif1hello_terragrunt-1536x365.png 1536w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GitHub-Moncif1hello_terragrunt.png 1778w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\"><a href=\"https:\/\/github.com\/Moncif1\/hello_terragrunt?source=post_page-----93c7b417e272--------------------------------\"><strong>GitHub &#8211; Moncif1\/hello_terragrunt<\/strong><\/a><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This project organises and manages different environments and modules, using Terragrunt to simplify the configuration and promote DRY principles.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The configuration is designed to be modular and reusable, with a central configuration inherited across different environments or modules.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This setup allows for centralising configurations, making it easier to manage and maintain common settings across multiple environments and modules. Any variables, remote state configurations, or other settings defined in the parent `terra grunt.hcl` will be applied to the module.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-keep-your-terraform-dry\">Keep Your Terraform Dry<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"987\" height=\"1024\" src=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terragrunt-architecture-987x1024.png\" alt=\"\" class=\"wp-image-84348\" style=\"width:500px\" srcset=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terragrunt-architecture-987x1024.png 987w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terragrunt-architecture-289x300.png 289w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terragrunt-architecture-768x797.png 768w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terragrunt-architecture.png 1172w\" sizes=\"auto, (max-width: 987px) 100vw, 987px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This architecture manages different environments (development, stageand production) and various components (db, gce, template, vpc).<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>terragrunt.hcl<\/strong> at the root level is used for setting global configurations applicable across all environments and modules.<\/li>\n\n\n\n<li><strong>common-vars.hcl<\/strong> contains common variable definitions shared among different modules and environments.<\/li>\n\n\n\n<li><strong>env-vars.hcl<\/strong> contains environment-specific variable definitions.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">You have different components (e.g., db, gce, template, vpc) in each environment. Each component directory contains its own terra grunt.hcl and module-vars.hcl files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Notes:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This Terragrunt Project does the following:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Loads Configuration Variables<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Module Variables<\/strong>: Loads module-specific variables from module-vars.hcl.<\/li>\n\n\n\n<li><strong>Common Variables<\/strong>: Loads common infrastructure variables from common-vars.hcl.<\/li>\n\n\n\n<li><strong>Environment Variables<\/strong>: Loads environment-specific variables from env-vars.hcl.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"512\" src=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Configuration-Variables-1024x512.png\" alt=\"\" class=\"wp-image-84387\" style=\"width:500px\" srcset=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Configuration-Variables-1024x512.png 1024w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Configuration-Variables-300x150.png 300w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Configuration-Variables-768x384.png 768w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Configuration-Variables.png 1208w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Remote State<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Creates Remote State for each component.<\/li>\n\n\n\n<li>Every component state will be managed in a different state file.<\/li>\n\n\n\n<li>Google Cloud Storage (GCS) is the backend for storing Terraform state files.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"558\" src=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-State-Files-1024x558.png\" alt=\"\" class=\"wp-image-84367\" style=\"width:500px\" srcset=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-State-Files-1024x558.png 1024w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-State-Files-300x163.png 300w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-State-Files-768x418.png 768w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-State-Files.png 1182w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Inputs<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Merges the variables from the common, environment, and module-specific configurations. (Pay attention to the order, the last value is the module value)<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"231\" src=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Inputs-1024x231.png\" alt=\"\" class=\"wp-image-84406\" style=\"width:500px\" srcset=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Inputs-1024x231.png 1024w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Inputs-300x68.png 300w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Inputs-768x173.png 768w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Inputs.png 1190w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>Terraform Source<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Specifies the source and version of the Terraform module to be used, which may vary across environments.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"167\" src=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-Source-1024x167.png\" alt=\"\" class=\"wp-image-84425\" style=\"width:500px\" srcset=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-Source-1024x167.png 1024w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-Source-300x49.png 300w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-Source-768x125.png 768w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-Source.png 1192w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li><strong>Components<\/strong><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Each component (such as DB (database)) or GCE (Google Compute Engine) makes use of Terragrunt\u2019s features, including inheriting parent configurations, managing dependencies, and dynamically passing inputs.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"616\" src=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-Terragrunt-Components-1024x616.png\" alt=\"\" class=\"wp-image-84444\" style=\"width:500px\" srcset=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-Terragrunt-Components-1024x616.png 1024w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-Terragrunt-Components-300x181.png 300w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-Terragrunt-Components-768x462.png 768w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-Terragrunt-Components.png 1190w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Terragrunt configuration file does the following:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Includes Parent Configuration<\/strong>: Inherits configurations from a parent <strong>terragrunt.hcl<\/strong> file, enabling consistent settings across environments and avoiding duplication.<\/li>\n\n\n\n<li><strong>Manages Dependencies<\/strong>: Defines a dependency to VPC (Virtual Private Cloud).<\/li>\n\n\n\n<li><strong>Passes Inputs<\/strong>: Uses the outputs from dependencies as inputs to other modules, allowing dynamic infrastructure management.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">By following this setup, you can manage your Terraform infrastructure dynamically and efficiently across different environments and modules, keeping it modular and maintainable.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-for-more-details-about-the-project-please-refer-to-the-readme-file\"><strong>For more details about the project, please refer to the README file.<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Usage:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Basic command:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Most Terragrunt commands use the Terraform command.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Terragrunt will automatically call Terragrunt init during other commands (e.g. terragrunt plan).<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"322\" src=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-commands-1024x322.png\" alt=\"\" class=\"wp-image-84468\" style=\"width:500px\" srcset=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-commands-1024x322.png 1024w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-commands-300x94.png 300w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-commands-768x241.png 768w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/Terraform-commands.png 1190w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can deploy the project (Hello World), by component or at once.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-use-the-power-of-terragrunt-for-cleaner-infrastructure-code\"><strong>Use the Power of Terragrunt for Cleaner Infrastructure Code<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this article, we have explored an example of using Terragrunt to deploy resources on Google Cloud (GCP) in different environments, showing the practical benefits of avoiding code duplication in Terraform adopting DRY practices.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By integrating Terragrunt into your workflow, you can streamline your infrastructure management, making your codebase cleaner, more organised, and easier to maintain over the long term.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<div class=\"wp-block-cover alignfull is-style-blur-image is-style-blur-image-less\" style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-right:0;padding-bottom:0;padding-left:0\"><span aria-hidden=\"true\" class=\"wp-block-cover__background has-black-background-color has-background-dim-70 has-background-dim\"><\/span><img loading=\"lazy\" decoding=\"async\" width=\"2560\" height=\"1708\" src=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584.jpg\" class=\"wp-block-cover__image-background wp-post-image\" alt=\"\" data-object-fit=\"cover\" srcset=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584.jpg 2560w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584-300x200.jpg 300w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584-1024x683.jpg 1024w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584-768x512.jpg 768w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584-1536x1025.jpg 1536w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584-2048x1366.jpg 2048w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><div class=\"wp-block-cover__inner-container is-layout-flow wp-block-cover-is-layout-flow\">\n<div class=\"wp-block-group alignfull has-base-color has-text-color has-global-padding is-layout-constrained wp-container-core-group-is-layout-46b67d08 wp-block-group-is-layout-constrained\" style=\"margin-top:0px;margin-bottom:0px;padding-top:var(--wp--preset--spacing--xxx-large);padding-right:var(--wp--preset--spacing--medium);padding-bottom:var(--wp--preset--spacing--xxx-large);padding-left:var(--wp--preset--spacing--medium)\">\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group has-global-padding is-content-justification-left is-layout-constrained wp-container-core-group-is-layout-5f9de3d0 wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading has-text-align-left has-secondary-font-family has-large-font-size\" id=\"h-ready-to-use-terragrunt-for-cleaner-infrastructure-code\">Ready to use Terragrunt for Cleaner Infrastructure Code?<\/h2>\n<\/div>\n\n\n\n<p class=\"has-text-align-left has-main-accent-color has-text-color wp-block-paragraph\">Contact our experts today! Let\u2019s chart a roadmap for seamless Terragrunt adoption for Google Cloud.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-left is-layout-flex wp-container-core-buttons-is-layout-3c38c079 wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/devoteam.info\/en-nl\/get-in-touch\/\">Get in touch<\/a><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will explore Terragrunt, a popular tool that promotes DRY (Don&#8217;t Repeat Yourself) practices and helps you use Terraform more effectively. DRY practices aim to reduce repetitive patterns and ensure that every piece of knowledge in your system has a single, unambiguous representation. We will also see how to use Terragrunt to [&hellip;]<\/p>\n","protected":false},"featured_media":84495,"template":"","categories":[902],"tags":[1069],"industry":[],"class_list":["post-518148","expert-view","type-expert-view","status-publish","has-post-thumbnail","hentry","category-google-cloud-en-nl","tag-uk-import-en-nl"],"acf":[],"cards":"\n\t<div class=\"single-post-card\">\n\n\t\t<figure class=\"wp-block-post-featured-image\"><a href=\"https:\/\/devoteam.info\/en-nl\/expert-view\/terragrunt-keep-terraform-dry\/\" target=\"_self\" ><img width=\"2560\" height=\"1708\" src=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584.jpg\" class=\"attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"Terragrunt: Keep Terraform DRY With A Clean and Efficient Code\" style=\"aspect-ratio:4\/3;width:100%;object-fit:cover;\" decoding=\"async\" loading=\"lazy\" srcset=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584.jpg 2560w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584-300x200.jpg 300w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584-1024x683.jpg 1024w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584-768x512.jpg 768w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584-1536x1025.jpg 1536w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584-2048x1366.jpg 2048w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><\/a><\/figure>\n\n\t\t\n\t\t<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-43282307 wp-block-group-is-layout-flex\">\n\t<p style=\"font-style:normal;font-weight:700\" class=\"has-link-color wp-elements-1 wp-block-lp-post-type has-text-color has-primary-color has-small-font-size\">Expert View<\/p>\n\n\t\t\n\t\t<h3 style=\"font-style:normal;font-weight:400\" class=\"wp-block-post-title has-base-font-size\"><a href=\"https:\/\/devoteam.info\/en-nl\/expert-view\/terragrunt-keep-terraform-dry\/\" target=\"_self\" >Terragrunt: Keep Terraform DRY With A Clean and Efficient Code<\/a><\/h3><\/div>\n\t\t\n\t<\/div>\n\n","yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.4 (Yoast SEO v28.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Terragrunt: Keep Terraform Dry With A Clean and Efficient Code<\/title>\n<meta name=\"description\" content=\"Learn how Terragrunt enhances Terraform by promoting DRY practices for cleaner, more maintainable code. Explore real-world examples and streamline your infrastructure management.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/devoteam.info\/en-nl\/expert-view\/terragrunt-keep-terraform-dry\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Terragrunt: Keep Terraform DRY With A Clean and Efficient Code\" \/>\n<meta property=\"og:description\" content=\"Learn how Terragrunt enhances Terraform by promoting DRY practices for cleaner, more maintainable code. Explore real-world examples and streamline your infrastructure management.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/devoteam.info\/en-nl\/expert-view\/terragrunt-keep-terraform-dry\/\" \/>\n<meta property=\"og:site_name\" content=\"Devoteam\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-07T10:18:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1708\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/terragrunt-keep-terraform-dry\\\/\",\"url\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/terragrunt-keep-terraform-dry\\\/\",\"name\":\"Terragrunt: Keep Terraform Dry With A Clean and Efficient Code\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/terragrunt-keep-terraform-dry\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/terragrunt-keep-terraform-dry\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/devoteam.info\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/GettyImages-904300584.jpg\",\"datePublished\":\"2024-11-18T15:16:19+00:00\",\"dateModified\":\"2025-05-07T10:18:53+00:00\",\"description\":\"Learn how Terragrunt enhances Terraform by promoting DRY practices for cleaner, more maintainable code. Explore real-world examples and streamline your infrastructure management.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/terragrunt-keep-terraform-dry\\\/#breadcrumb\"},\"inLanguage\":\"en-NL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/terragrunt-keep-terraform-dry\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-NL\",\"@id\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/terragrunt-keep-terraform-dry\\\/#primaryimage\",\"url\":\"https:\\\/\\\/devoteam.info\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/GettyImages-904300584.jpg\",\"contentUrl\":\"https:\\\/\\\/devoteam.info\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/GettyImages-904300584.jpg\",\"width\":2560,\"height\":1708},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/terragrunt-keep-terraform-dry\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Expert View\",\"item\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Terragrunt: Keep Terraform DRY With A Clean and Efficient Code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/#website\",\"url\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/\",\"name\":\"Devoteam\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-NL\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Terragrunt: Keep Terraform Dry With A Clean and Efficient Code","description":"Learn how Terragrunt enhances Terraform by promoting DRY practices for cleaner, more maintainable code. Explore real-world examples and streamline your infrastructure management.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/devoteam.info\/en-nl\/expert-view\/terragrunt-keep-terraform-dry\/","og_locale":"en_US","og_type":"article","og_title":"Terragrunt: Keep Terraform DRY With A Clean and Efficient Code","og_description":"Learn how Terragrunt enhances Terraform by promoting DRY practices for cleaner, more maintainable code. Explore real-world examples and streamline your infrastructure management.","og_url":"https:\/\/devoteam.info\/en-nl\/expert-view\/terragrunt-keep-terraform-dry\/","og_site_name":"Devoteam","article_modified_time":"2025-05-07T10:18:53+00:00","og_image":[{"width":2560,"height":1708,"url":"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/devoteam.info\/en-nl\/expert-view\/terragrunt-keep-terraform-dry\/","url":"https:\/\/devoteam.info\/en-nl\/expert-view\/terragrunt-keep-terraform-dry\/","name":"Terragrunt: Keep Terraform Dry With A Clean and Efficient Code","isPartOf":{"@id":"https:\/\/devoteam.info\/en-nl\/#website"},"primaryImageOfPage":{"@id":"https:\/\/devoteam.info\/en-nl\/expert-view\/terragrunt-keep-terraform-dry\/#primaryimage"},"image":{"@id":"https:\/\/devoteam.info\/en-nl\/expert-view\/terragrunt-keep-terraform-dry\/#primaryimage"},"thumbnailUrl":"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584.jpg","datePublished":"2024-11-18T15:16:19+00:00","dateModified":"2025-05-07T10:18:53+00:00","description":"Learn how Terragrunt enhances Terraform by promoting DRY practices for cleaner, more maintainable code. Explore real-world examples and streamline your infrastructure management.","breadcrumb":{"@id":"https:\/\/devoteam.info\/en-nl\/expert-view\/terragrunt-keep-terraform-dry\/#breadcrumb"},"inLanguage":"en-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/devoteam.info\/en-nl\/expert-view\/terragrunt-keep-terraform-dry\/"]}]},{"@type":"ImageObject","inLanguage":"en-NL","@id":"https:\/\/devoteam.info\/en-nl\/expert-view\/terragrunt-keep-terraform-dry\/#primaryimage","url":"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584.jpg","contentUrl":"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584.jpg","width":2560,"height":1708},{"@type":"BreadcrumbList","@id":"https:\/\/devoteam.info\/en-nl\/expert-view\/terragrunt-keep-terraform-dry\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/devoteam.info\/en-nl\/"},{"@type":"ListItem","position":2,"name":"Expert View","item":"https:\/\/devoteam.info\/en-nl\/expert-view\/"},{"@type":"ListItem","position":3,"name":"Terragrunt: Keep Terraform DRY With A Clean and Efficient Code"}]},{"@type":"WebSite","@id":"https:\/\/devoteam.info\/en-nl\/#website","url":"https:\/\/devoteam.info\/en-nl\/","name":"Devoteam","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/devoteam.info\/en-nl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-NL"}]}},"uagb_featured_image_src":{"full":["https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584.jpg",2560,1708,false],"thumbnail":["https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584-150x150.jpg",150,150,true],"medium":["https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584-300x200.jpg",300,200,true],"medium_large":["https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584-768x512.jpg",768,512,true],"large":["https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584-1024x683.jpg",1024,683,true],"1536x1536":["https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584-1536x1025.jpg",1536,1025,true],"2048x2048":["https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-904300584-2048x1366.jpg",2048,1366,true]},"uagb_author_info":{"display_name":"uk.emma","author_link":"https:\/\/devoteam.info\/en-nl\/author\/"},"uagb_comment_info":0,"uagb_excerpt":"In this article, we will explore Terragrunt, a popular tool that promotes DRY (Don&#8217;t Repeat Yourself) practices and helps you use Terraform more effectively. DRY practices aim to reduce repetitive patterns and ensure that every piece of knowledge in your system has a single, unambiguous representation. We will also see how to use Terragrunt to&hellip;","_links":{"self":[{"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/expert-view\/518148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/expert-view"}],"about":[{"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/types\/expert-view"}],"version-history":[{"count":0,"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/expert-view\/518148\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/media\/84495"}],"wp:attachment":[{"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/media?parent=518148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/categories?post=518148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/tags?post=518148"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/industry?post=518148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}