First time at Zeet?

6 Apr
min read

Terragrunt vs Terraspace: Comparing Terraform Force Multipliers

Learn about Terragrunt vs Terraspace. What is easier to use? What makes most sense for your project? Learn all about it in this blog post.

Jack Dwyer

How To

Share this article

Overview of the Infrastructure as Code Landscape

coding for Terragrunt vs Terraspace

Let's start by breaking down the concept of Infrastructure as Code (IaC), a vital element in modern software development and cloud infrastructure management. IaC involves managing and provisioning technology infrastructure using machine-readable configuration files instead of interactive configuration tools or physical hardware configuration. What is Terraform, anyway? An open-source IaC tool created by HashiCorp, stands out as a popular choice due to its open-source nature, declarative format, resource lifecycle management, state management, and module reusability. Terraform enables users to define and provision data center infrastructure across public and private cloud providers.

Necessity of Terragrunt and Terraspace in Enhancing Terraform's Capabilities

Let's delve into the significance of additional tools like Terragrunt and Terraspace in bolstering Terraform's functionality. Terragrunt serves as a thin wrapper that gives a sane way to organize your Terraform code to keep it DRY, thus helping to maintain large Terraform codebases composed of multiple modules. Terraspace automates the process of managing multiple Terraform modules within a single project, simplifying testing by providing a test harness and making it easier to manage state files.

Elevate Your Cloud Deployments with Zeet

Zeet helps you to get more from your cloud, Kubernetes, and Terraform investments and helps your engineering team become strong individual contributors through our CI/CD & deployment platform. 

Contact Zeet to learn more about how Zeet helps you get seamless cloud deployments every time, and helps your team to become a top-performing engineering team.

Related Reading

Terraform Getting Started
Infrastructure As Code Best Practices
Terraform Best Practices

What is Terragrunt? 

code is written to differentiate Terragrunt vs Terraspace

Terragrunt is a powerful tool often used to alleviate the complexities and challenges associated with Terraform. It allows us to write Terraform configurations in an organized way, keeping the code DRY, and automating backend creation. It is a thin wrapper tool that offers a variety of features like CLI hooks, which provide us with the ability to deploy all infrastructure easily.

Key features and benefits of Terragrunt

1. DRY (Don't Repeat Yourself) Code Principle

Terragrunt ensures that we write reusable and maintainable code by following the DRY principle.

2. Remote State Management and Locking

It aids in team collaboration by managing remote state files and ensuring that only one user can modify the infrastructure at a time.

3. Code and State File Separation

Terragrunt helps in keeping the code and state files separate, improving organization.

4. Automatic Retrieval of Dependencies

Dependencies such as modules and remote state files are automatically fetched by Terragrunt.

5. Support for Data Sources and Dependencies

This tool also supports data sources and dependencies across multiple Terraform configurations.

6. Easy Configuration

Terragrunt is easy to configure using .terragrunt files.

Use cases and scenarios where Terragrunt shines

Terragrunt is beneficial in large-scale deployments, multi-account setups, and team collaboration. It simplifies the management of complex Terraform codebases and ensures that code remains organized and maintainable throughout the infrastructure's lifecycle.

Process of setting up and using Terragrunt

1. Installation and Configuration

To set up Terragrunt, you need to install Terraform first. Once Terraform is installed, you can move on to installing Terragrunt using various methods like Homebrew (for macOS) or Chocolatey (for Windows). The next step involves creating a Terragrunt configuration file called terragrunt.hcl in the same directory as your Terraform files.

2. Basic Commands and Workflow

Terragrunt provides a similar set of commands to Terraform with additional features. Commands like terragrunt init, terragrunt plan, terragrunt apply, terragrunt output, and terragrunt destroy are commonly used. The typical workflow includes initializing the directory, creating an execution plan, applying changes, retrieving output values, and destroying resources.

3. Integrating with Terraform workflows

Terragrunt is often integrated with existing Terraform workflows. It can be incorporated into CI/CD pipelines, code repositories, Terraform Cloud/Enterprise, and automation scripts. By using Terragrunt with Terraform workflows, you can automate infrastructure provisioning, enable collaboration, and enhance governance.

Maximizing Cloud Deployment Efficiency with Zeet

Contact Zeet to learn more about how Zeet can help you get seamless cloud deployments every time and help your engineering team become strong individual contributors.

Zeet Terraform and Helm Product Overview

What is Terraspace?

coding is written on a laptop for Terragrunt vs Terraspace

Terraspace is a full-fledged framework that simplifies and streamlines your Terraform workflow. It adheres to the convention over configuration principle, providing a conventional project structure with defaults that work right out of the box. Terraspace extends Terraform by removing duplicate configuration files, automating backend creation for all three major cloud providers, and offering a plethora of configurable knobs and switches.

Terraspace also boasts a concise and cleaner CLI hook syntax, making it intuitive and straightforward to use. Additionally, it's highly customizable, with over 20 core framework settings and numerous options for provider plugins, CLI hooks, and customizable arguments.

Key Features of Terraspace

1. Convention over Configuration Principle

Terraspace's defaults work right out of the box, eliminating the need for extensive configurations.

2. Modules as Code

Terraform modules are defined as Ruby code in Terraspace.

3. Testing and Debugging

Terraspace provides built-in support for testing and debugging infrastructure code.

4. Layered Configuration Approach

Utilize configurable layers for applications, environments, and components.

5. Hooks and Callbacks

Execute custom Ruby code at various stages of the workflow.

6. Cloud-Agnostic

Supports any Terraform provider, making it versatile and flexible.

Use Cases and Scenarios

Terraspace excels in complex deployments, testing, and custom workflows. Whether you're orchestrating intricate infrastructure setups, ensuring your code is robust with extensive testing, or tailoring workflows to unique requirements, Terraspace provides the tools and flexibility to navigate these scenarios effectively.

Setting Up and Using Terraspace

1. Installation and Configuration

Terraspace is a Ruby gem, requiring Ruby to be installed on your system. Once Ruby is set up, install the Terraspace gem using the command `gem install terraspace`. Verify the installation with `terraspace --version`.

2. Basic Commands and Workflow

Terraspace offers commands such as `up`, `down`, `plan`, `output`, and `test` for managing infrastructure code. The workflow involves defining infrastructure code, creating an execution plan, applying changes, testing, and cleanup as needed.

Integrating with Terraform Workflows

Terraspace seamlessly integrates with Terraform workflows, empowering you to leverage existing processes effortlessly. Integration scenarios include CI/CD pipelines, code repositories, Terraform Cloud/Enterprise, and automation scripts. Terraspace commands are designed to work seamlessly with Terraform, bridging the gap between the two tools effectively.

Achieving Seamless Cloud Deployments with Zeet

Ready to take your cloud deployments to the next level? Contact Zeet to learn more about how Zeet can help you get seamless cloud deployments every time, driving your engineering team to peak performance.

Related Reading

In-Depth Terragrunt vs Terraspace Comparison

Diary, phone, camera and a laptop on a table. Coding is being done to compare Terragrunt vs Terraspace

Automated Project Creation (directories and backing resources)

Terragrunt and Terraspace both offer a way to initialize state management backing resources automatically. Terragrunt uses the terragrunt.hcl file, while Terraspace uses regular *.tf files in the /config directory combined with Ruby's templating engine.

Project Directories Structure

Terragrunt allows flexibility in project structure, offering recommendations but not enforcing any specific structure. On the other hand, Terraspace enforces a strict and predefined directory structure, making all projects structured similarly and easy to understand.

Multiple Environments Handling

Terragrunt requires multiple directories for different environments, while Terraspace handles environment selection using the TS_ENV variable, allowing for customization using the tfvars directory.

Local/global variables handling

Terragrunt allows developers to define variables at different levels in the directory structure, while Terraspace uses the tfvars files for variable definitions and offers flexibility using Ruby helper functions.

Working with multiple stacks and handling dependencies

Both Terragrunt and Terraspace offer convenient commands for executing against multiple stacks, with Terraspace using a mock attribute for dependent output definition.

External/3rd Party Modules Handling

Terragrunt uses regular Terraform module source syntax, while Terraspace allows developers to declare external modules using the Terrafile file, downloading them to the local vendor/modules directory.

Testing capabilities

Terragrunt does not offer built-in testing capabilities, while Terraspace integrates testing capabilities based on Ruby's RSpec, offering a set of helper functions for Terraform configuration and lifecycle control.

Extensions and hooks

Terragrunt offers hooks before/after Terraform commands, while Terraspace provides the flexibility of custom functions written in Ruby for use in *.tf files, offering a richer set of possibilities for customization.

Debugging of generated Terraform code

Both Terragrunt and Terraspace offer a way to check the generated Terraform code, with Terragrunt's configuration in the terragrunt-cache directory and Terraspace's in .terraspace-cache.

Maximizing Cloud Investments and Empowering Engineering Teams with Zeet

Zeet helps you to get more from your cloud, Kubernetes, and Terraform investments and helps your engineering team become strong individual contributors through our CI/CD & deployment platform. 

Contact Zeet to learn more about how Zeet helps you get seamless cloud deployments every time, and helps your team to become a top-performing engineering team.

Terragrunt vs Terraspace: Choosing the Right Tool

women explaining a difference in Terragrunt vs Terraspace software

Project Complexity and Scale

I would suggest evaluating the complexity and scale of your project before deciding between Terragrunt and Terraspace. Terragrunt excels in handling large-scale and intricate deployments with multiple Terraform configurations and interdependencies. On the other hand, Terraspace's modular approach and convention over configuration principle make it a better fit for projects with high complexity levels.

Team Size and Collaboration Needs

Consider the size of your team and the collaboration requirements before choosing between Terragrunt and Terraspace. Terragrunt is recommended for large teams working on infrastructure code, as its support for remote state management, locking mechanisms, and code reusability can promote better collaboration and prevent conflicts. However, if you have a smaller team or collaboration is less of a concern, Terraspace's convention-based approach might be a simpler and lighter alternative.

Existing Skills and Familiarity

Take into account your team's existing skills and familiarity with the tools. If your team is already well-versed in HashiCorp Configuration Language (HCL) and Terraform, adopting Terragrunt could be easier due to its usage of the same syntax and concepts. Conversely, if your team has strong Ruby skills or prefers working with code over configuration files, Terraspace's Ruby-based approach might be more suitable.

Testing and Debugging Requirements

Assess your project's testing and debugging needs before choosing between Terragrunt and Terraspace. While Terragrunt lacks built-in testing capabilities, it can be integrated with third-party testing frameworks and tools for Terraform. Terraspace, however, provides built-in support for testing and debugging infrastructure code, making it more appealing for projects where testing is a crucial requirement.

Cloud Provider Support and Portability

Both Terragrunt and Terraspace are cloud-agnostic and are compatible with any Terraform provider. This allows you to manage infrastructure across numerous cloud providers or on-premises environments. Therefore, cloud provider support and portability may not be significant deciding factors when choosing between Terragrunt and Terraspace.

Complementary Usage

While Terragrunt and Terraspace are usually seen as alternatives, they can be used together or complement each other in various scenarios. For instance, you can use Terragrunt for managing remote state and dependencies across multiple Terraform configurations and leverage Terraspace for modular infrastructure code and testing within individual components.

Migration Paths

If you're considering migrating from one tool to the other, there are potential migration paths and strategies to follow. For instance, when moving from Terragrunt to Terraspace, you can begin by converting individual Terraform configurations or components to Terraspace modules and gradually phase out Terragrunt as more infrastructure is migrated. 

Conversely, if you're transitioning from Terraspace to Terragrunt, you can extract common configurations and remote state management from Terraspace into Terragrunt while retaining the modular infrastructure code in Terraspace.

Zeet Contact Us

Related Reading

Get Control of Your Releases With Zeet's CI/CD & Deployment Platform for Kubernetes and Terraform

man using a laptop analyzing Terragrunt vs Terraspace

Zeet helps you to get more from your cloud, Kubernetes, and Terraform investments and helps your engineering team become strong individual contributors through our CI/CD & deployment platform. Our platform simplifies and accelerates deployments and helps your team to become a top-performing engineering team. 

Contact Zeet to learn more about how our platform can help you streamline your cloud deployments and optimize your Terraform workflow. Let us help you get the most from your cloud and Kubernetes investments. Let us help your engineering team become high-performing individual contributors. 

Let us help you get seamless cloud deployments every time.

Subscribe to Changelog newsletter

Jack from the Zeet team shares DevOps & SRE learnings, top articles, and new Zeet features in a twice-a-month newsletter.

Thank you!

Your submission has been processed
Oops! Something went wrong while submitting the form.