Back

terramate.io

10 Biggest Pitfalls of Terraform - Terramate

10/6/2023Updated 3/27/2026
https://terramate.io/rethinking-iac/10-biggest-pitfalls-of-terraform/

Terraform (or OpenTofu if you prefer open source) has emerged as a pivotal player in the evolving Infrastructure as Code (IaC) landscape, facilitating the management and provision of cloud resources through code. However, like any tool, it has drawbacks and tradeoffs. Challenges such as **managing multiple environments with workspaces**, **maintaining module versions** and **backend configurations**, and** managing resource lifecycles** often make Terraform code hard to read and prone to errors. Moreover, scaling can be cumbersome due to a lack of stack concept, leading to complications in more intricate environments. … ## 1. Terraform Workspaces Terraform Workspaces help you manage different environments, like staging, development, and production. However, they can be tricky to handle. For example, the code can be difficult to understand because you have to use the `count` parameter a lot to create resources based on conditions. Also, it gets harder when you want to scale or grow with Terraform Workspaces because you need to add more connections between them when managing different environments. … ## 2. Maintaining Module Versions In Terraform, a feature called the module block lets users use pre-set modules. But there's a problem with this block. The `source` and `version` attributes in this block, which are used to specify where the module comes from and which version of the module to use, don't allow for variable interpolation. Variable interpolation is replacing a placeholder in a string with its actual value. This limitation can cause trouble when you're trying to set up modules in a flexible or dynamic way. … ## 3. Hardcoding Backend Configuration When you’re working with Terraform, you might need to make copies of Root Modules, but this can cause unexpected problems if you’re not careful with the backend configuration. The backend configuration is where Terraform stores information about your infrastructure. If you copy the backend configuration without changing the `key` or `prefix` (which identifies the location of the stored information), it can cause problems. For example, you might end up with destructive Terraform Plans, which can potentially damage your infrastructure if the wrong state file (a file that keeps track of the status of your infrastructure) is referenced. … ## 4. Provider Config With Terraform, managing the provider configuration involves a lot of repetitive coding and manual work. The provider configuration is part of the code that tells Terraform how to interact with the service you’re using, like AWS or Google Cloud. Duplicating and manually managing this code can lead to mistakes and waste time. Here’s where Terramate can make things easier with its code generation feature. This feature can take a simple user configuration and generate more complicated provider configurations. This simplifies managing the provider configuration and reduces the duplicate code you need to write. … ## 7. Missing Stack Concept Terraform is unique in the world of IaC tools because it doesn’t have a stack concept. A stack is a collection of resources that are managed together. Instead, Terraform only focuses on what’s happening within a single directory, a root module. This can cause problems when dealing with bigger, more complex environments because it’s not designed to handle multiple collections of resources at once. … ## 8. Code Duplication In Terraform, when you want to use a module (which is a pre-set piece of code) multiple times, you have to copy the call to the module and the arguments (the specific instructions you give to the module) each time. This leads to repeated code, making your codebase larger and harder to maintain. … # 9. Monostacks If you’re managing a lot of resources (like virtual machines, databases, etc.) in Terraform, it can cause some problems. For example, if something goes wrong, it could affect many of your resources (this is known as a “big blast radius”). Also, executing plans and applying changes can take a long time when dealing with many resources. Additionally, if there are discrepancies or “drifts” in a single resource, it can prevent you from applying new changes. … ## 10. Deep Merging of Maps and Objects In Terraform, merging or combining maps and objects at multiple levels, also known as “deep merging”, is not allowed. A map is a collection of key-value pairs, and an object is a complex structure containing multiple data types. This limitation makes it hard to merge default configurations with user inputs. For instance, it’s difficult to create keys or attributes that conflict, and changing the value of an attribute in a nested structure is impossible. … ## Conclusion Terraform has played a key role in popularizing the concept of Infrastructure as Code, where you manage your IT infrastructure using code. However, it’s not without its challenges. These include issues like code that is hard to read, difficulty scaling with workspaces, problems maintaining versions of modules, the need to hardcode backend configurations and the complexity of managing the lifecycle of resources.

Related Pain Points7

Hardcoded backend configuration leads to destructive state file mismatches

9

When copying root modules without updating backend configuration (key/prefix), Terraform can reference the wrong state file, resulting in destructive plans that delete infrastructure belonging to another environment or project.

configTerraformstate backends

Missing stack concept prevents grouped resource management and scaling

7

Unlike other IaC tools, Terraform lacks a stack concept for managing collections of related resources. It only operates at the root module level, making it difficult to manage large, complex environments with multiple resource groupings without custom orchestration.

architectureTerraform

Monolithic state files with large resource counts cause blast radius and performance degradation

7

Managing many resources in a single Terraform state increases blast radius (a single error affects many resources), slows plan/apply execution, and prevents new changes if any resource drifts. Resource drift in one resource blocks the entire apply.

performanceTerraformstate

Module version source attribute does not support variable interpolation

6

The source and version attributes in Terraform's module block reject variable interpolation, preventing dynamic module sourcing. This limitation breaks flexible, parameterized module management patterns and forces hardcoded or copy-paste module references.

configTerraformmodules

Workspace-based multi-environment management requires excessive conditional logic

6

Using Terraform workspaces to manage multiple environments (dev, staging, prod) requires heavy use of count parameters and conditional expressions, making code difficult to read and understand. Scaling across environments becomes increasingly complex as interconnections multiply.

dxTerraformworkspaces

Provider configuration repetition and manual management of duplicated code

5

Terraform requires manual, repetitive copy-paste of provider configuration across multiple modules and environments. This duplication increases maintenance burden and introduces errors when updating provider settings.

dxTerraformproviders

Shallow merge() function prevents nested configuration composition

5

Terraform's merge() function only performs shallow merging, not deep merging of nested maps and objects. This prevents clean composition of default configurations with user-supplied overrides and makes merging multi-level data structures awkward.

dxTerraformHCL