Back

Working with Terraform Can Be Much Faster

Fast Feedback with Terraform
Jye CuschJye Cusch

Jye Cusch

7 min read

Building for cloud environments with infrastructure automation often feels unproductive due to the slow feedback loop between making a change and seeing its impacts. I'm sure you know what I'm talking about. You push a change, and then... you wait. You wait for the infrastructure to spin up, for tests to run, and for builds to complete. During this waiting period, it's tempting to switch to another task. But this context switching, as many of us have experienced, isn't as productive as it seems. Reorienting yourself back to the original task once feedback is available consumes precious time and disrupts the flow of work.

Alternatively, you might find yourself simply waiting for the feedback to come through. This idle time, even if it's just a few minutes here and there, adds up. I've found myself staring at the screen, watching the progress bar inch forward, knowing that these cumulative delays are silently eating away hours of productive time each week.

The quality of our work also takes a hit from these slow feedback loops. Infrequent testing becomes a norm, as running tests regularly is discouraged by the time they take. This leads to larger batches of changes being tested together, making it harder to pinpoint the source of issues. Bugs accumulate, and we often proceed with false assumptions, only to later realize that a fundamental part of our code doesn't work as intended. The longer it takes to get feedback, the more likely we are to write unverified code, increasing the risk of errors and bugs.

Moreover, slow feedback loops stretch out our development cycles. Each iteration takes longer or we achieve less, reducing the overall throughput and delaying the project. Problems that could have been caught early are detected much later, making them more challenging and costly to fix. This delay in problem detection is not just a technical issue but a morale killer as well. The constant waiting and the resulting slower progress can be incredibly frustrating, sapping the joy out of what should be an engaging and creative process.

This frustration can also lead to increased stress. The pressure to meet deadlines while dealing with slow feedback loops contributes to burnout. We start postponing necessary refactoring and opt for quick fixes rather than well-thought-out solutions. This mindset, driven by the need to avoid slow and frustrating changes, leads to the accumulation of technical debt, making future changes even harder.

In the end, working with slow feedback loops in cloud environments feels like trudging through mud. It hinders productivity, compromises quality, extends development cycles, and saps morale.

Where the feedback slows down with Terraform

As many of you are already aware, Infrastructure as Code (IaC) tools like Terraform offer significant benefits but also introduce challenges, particularly around quick iteration and feedback. Let's revisit where Terraform can slow things down.

One primary issue is the time it takes to execute plan and apply operations. Deploying complex infrastructures or large numbers of resources can be time-consuming, often dependent on the performance of the target provider. This delay in execution is frustrating when you're eager to see the impact of your changes.

State management is another slow point. As the Terraform state file grows, operations on it become slower, leading to performance bottlenecks. Managing large state files is cumbersome and can slow down feedback. Additionally, Terraform locks the state during operations to prevent concurrent modifications, causing delays if multiple team members are working on the same state.

Using remote backends for state storage introduces network latency. The speed of state retrieval and updates depends on network performance and the backend's efficiency, adding to the overall delay.

Complex Terraform configurations and modules also contribute to slower feedback. Large and intricate modules take more time to process and apply, especially with heavy use of interpolation and dependencies.

Error diagnosis and debugging can be challenging, often requiring multiple cycles of trial and error. This prolongs the feedback loop and tests your patience, one of the most common frustrations I hear. Sometimes it feels like you're just guessing what will work in a live environment. Immediate feedback is hard to obtain when changes must be tested in a fully operational setup, adding more delay.

In summary, while Terraform brings many advantages, it also introduces several points where the feedback loop can slow down significantly. These delays are often due to factors outside Terraform's direct control, such as the performance of remote systems and the complex nature of cloud resources. Understanding these slow points is crucial to finding ways to mitigate them and improve the overall development experience.

Enter Infrastructure from Code

Infrastructure from Code (IfC) tools address many of the feedback issues we've discussed. They allow local simulation, ensure deployment of pre-tested infrastructure, and provide working default configurations right from the start. If you're new to IfC, you might want to check out how it compares to IaC in this blog from Tim or this comparison of Terraform and Nitric (which can generate Terraform) before continuing.

Increased Efficiency

The long waits during plan and apply operations with Terraform are easily mitigated. IfC tools reduce this pain by automatically generating Terraform that works out-of-the-box. This means less time manually writing and testing infrastructure code, giving you faster feedback and more time to focus on what really matters – building your application.

Reduced Errors

Handling large state files and managing dependencies can introduce human error, leading to unreliable infrastructure setups and frequent bugs. With IfC, automation takes over, minimizing these errors. By avoiding common pitfalls and the need for trial-and-error deployments, IfC ensures that the infrastructure is robust from the beginning.

Enhanced Productivity

We talked about how context switching and idle time reduce productivity. IfC tools help mitigate this by allowing developers to focus on core development tasks rather than being bogged down with infrastructure. With infrastructure automatically handled, workflows become more streamlined, enabling quicker iterations and deployments.

Consistency and Standardization

Inconsistent infrastructure configurations and state locking issues can slow you down. IfC addresses this by ensuring that all generated Terraform is consistent across different environments, reducing discrepancies and potential conflicts. Additionally, these tools embed best practices and security standards, ensuring that your infrastructure adheres to high standards and uses pre-tested modules.

Cost and Resource Optimization

Network latency and backend performance can throttle your progress. Running tests locally with IfC tools reduces the need for cloud resources during the development phase, cutting costs and allowing for more rapid testing. The automatic generation of code is also optimized for efficiency, ensuring that resources are used effectively.

Ultimately, configuring an API Gateway or wiring up serverless function triggers isn't where your product's unique value lies. Just as modern programming languages and software libraries provide valuable abstractions to improve development velocity, Infrastructure from Code offers similar abstractions for deployed infrastructure. This makes development easier but also enhances productivity, allowing you to focus on creating value and innovation.

If you're interested in exploring Infrastructure from Code, see our guide on getting started with Nitric or the comparison with Terraform. If you have other questions or want to learn more from the community, consider joining us on Discord

Previous Post
Terraform vs Pulumi: Which IaC tool is right for you?
Next Post
Maximizing Terraform Modules for Platform Engineering