
Gergő Nagy
· 5 min read
Boilerplate – What’s the Problem with Copy-Paste Solutions?
Starting new IaC projects no longer means manual copy-pasting. In this article, you’ll learn how the Gruntwork Boilerplate–based template helps create new infrastructure projects quickly and consistently, and how we simplify the initial steps.

In Terragrunt projects, a recurring challenge is the lack of structural consistency. When teams repeatedly set up the project foundations manually, it not only takes extra time but also introduces a high risk of errors. This kind of repetitive setup slows down the start of new projects, complicates collaboration between teams, and in the long run makes code auditing and maintenance much more difficult.
Our Solution:
Our company has developed an open-source Terragrunt template built on top of the Gruntwork Boilerplate tool. With this, project initialization becomes not only faster but also more standardized and transparent.
boilerplate --template-url <remote-template> --output-folder <target-path>
boilerplate --var-file vars.yml --non-interactive --template-url <source>
The tool supports both local and remote template sources, making it easy to establish and maintain a central repository. In this repository, we can keep Tofu modules up to date and also store ready-made base configurations—for example, for an EKS cluster.
Why Is It Needed?
Using predefined templates offers numerous advantages for development teams. It significantly shortens the onboarding time for new team members while eliminating the risk of copy-paste errors. Projects are built on a consistent architecture, making code review processes simpler and teamwork more transparent. In addition, templates embed best practices into daily work and are version-controlled, ensuring that changes can be tracked reliably over time.
What Is Boilerplate?
Boilerplate, developed by Gruntwork, is a tool that allows the dynamic creation of files and file structures based on predefined templates. Learn more: jump to the sources at the end of the article.
Let’s take the example of a new Terragrunt project. Such projects typically follow a very similar structure: organized into environments, containing accounts, regions, units, and stacks. This structure is repetitive and template-like—making it an ideal candidate for automation.
With Boilerplate, we can do exactly that: predefine folder names, account IDs, and other variables, then build the project either interactively or fully automated with non-interactive commands. Instead of manually copying the structure each time, we can quickly and reliably generate the required foundation.
How Do We Use It at Code Factory?
In our solution, we opted for the terragrunt-stack structure and defined two basic starting types: single-account and multi-account projects.

The process is simplified by presets: the user selects the appropriate preset, provides the necessary variables, and within just a few steps a complete base project is created, ready for deployment immediately.

The generated project is built from two main directories. The infrastructure directory contains the IaC code—that is, everything within the scope of Terragrunt (this is where Terragrunt commands should be executed). The other directory, units, is used for preparing the modules that Terragrunt uses as sources.

.
├── infrastructure
│ ├── live
│ │ ├── development
│ │ │ ├── account.hcl
│ │ │ └── eu-central-1
│ │ │ ├── eks-managed
│ │ │ │ └── terragrunt.stack.hcl
│ │ │ └── region.hcl
│ │ ├── management
│ │ │ └── ...
│ │ ├── monitoring
│ │ │ └── ...
│ │ └── production
│ │ └── ...
│ ├── project.hcl
│ └── root.hcl
├── mise.toml
├── report-module-versions.sh
├── terraform
│ ├── cross-account-role
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ └── vars.tf
│ └── eks-addon
│ └── ...
└── units
├── eks-auto
│ └── ...
├── eks-managed
│ ├── aws-lbc
│ │ └── terragrunt.hcl
│ ├── cross-account-role
│ │ └── terragrunt.hcl
│ ├── eks
│ │ └── terragrunt.hcl
│ ├── eks-addon
│ │ └── terragrunt.hcl
│ ├── iam-role
│ │ └── terragrunt.hcl
│ ├── kms
│ │ └── terragrunt.hcl
│ └── vpc
│ └── terragrunt.hcl
├── vpc
│ └── ...
└── web
└── ...
This directory also contains the report-module-versions.sh
script, which generates a list of the currently used community modules and indicates if newer versions are available. This greatly simplifies tracking updates.
In addition, an extra preset is available: the Terragrunt stack, which makes it possible to add new stacks to an existing project. In this case, the user can freely decide whether to generate the units directly in their final location based on the path, or place them later within the project. This provides a flexible and highly scalable solution for continuously growing infrastructures.

How to Use It?
Using Boilerplate is simple. First, you need to download the binary file from the Gruntwork website, then provide the template source when running it—this can be either a local directory or a remote URL—and specify the target path where the generated project will be created.
If you want to use a configuration file, you can pass it to the command using a separate flag. For example, with the --var-file vars.yml --non-interactive
option, the entire process can be fully automated, and the project can be generated in just a few seconds.
Give it a try!
boilerplate --template-url "github.com/codefactoryhu/terragrunt-aws-boilerplate//terragrunt-boilerplate?ref=main" \
--output-folder ~/Desktop/code-factory-boilerplate/new-project
Summary
Boilerplate can be used not only for creating IaC structures but also for setting up any kind of project structure. A unified project structure makes it easier for new team members to navigate an unfamiliar project. Creating your own template is also simple — the Boilerplate GitHub link can be found in the sources.
Thank you for reading this article!
Are you interested in this topic? Do you have any questions about the article? Book a free consultation and let’s see how the Code Factory team can help you! You can find a list of our services here!
Sources:
- Code Factory Boilerplate - GitHub Link – Our own templating repository for IaC projects.
- Gruntwork Boilerplate - GitHub Link – A tool for generating files and folders (“boilerplate”) from a set of templates.
- Gruntwork Terragrunt - GitHub Link – Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
- Tool Releases - GitHub Link