Stack Builders logo
Arrow icon Insights

Combining Nix with Terraform for better DevOps

We're thrilled to announce the release of nixpkgs-terraform, a game-changer for your Terraform environment. Forget about documentation hassles and effortlessly keep your team on the same version with its declarative and reproducible installation. Dive into the future of DevOps with Stack Builders!

An investment in creating the best software in the world will still go to waste if the infrastructure it runs on isn’t well-managed. At Stack Builders, our mission is to push the boundaries of the software industry through quality, pragmatic solutions that bring to life our client's vision, and one way we are doing this is to leverage our training and staff experience with functional programming to make DevOps better.

In that light, we’re thrilled to announce the release of nixpkgs-terraform! This Nix project significantly enhances the flexibility and control of your Terraform environment, making its installation and management declarative and reproducible. This is largely thanks to Nix and its unique capabilities for precisely pinning packages to a version, ensuring its consistency across different environments. Forget about writing documentation on environment setup - just use one of the provided templates to bootstrap your Terraform installation and get the whole team on the same version with minimal manual intervention.

No need for deep knowledge of Nix either - just keep adding tools to your template of choice to craft a reproducible, declarative, and portable development environment for everyone on the project so that you can focus on what matters.

At Stack Builders, our DevOps/SRE team uses nixpkgs-terraform along with devenv to create portable development environments where we have fine-grained control over the Terraform version to work on various Infrastructure-as-Code projects across the board. Here's an example of a common devenv file used in our projects:

{ pkgs,  }:

{
  packages = [
    pkgs.aws-vault
    pkgs.trivy
  ];

  languages.terraform.enable = true;
  languages.terraform.version = 1.9;

  pre-commit.hooks.terraform-format.enable = true;
  pre-commit.hooks.tflint.enable = true;
}

We’ve noticed that some users have been asking about how to use older versions of Terraform in their Nix setups [1, 2]. This is an example of the diverse needs of people and the importance of maintaining backward compatibility. We hope that nixpkgs-terraform will be a useful tool for these users.

The design of nixpkgs-terraform follows a bottom-up approach, making it more approachable for newcomers. We hope this will empower everyone to take their Nix experience to the next level!

Looking forward to your feedback and contributions. Happy Nixing!

Read our full white paper which explores the larger terrain of DevOps tooling and technologies: Practical DevOps: Navigating the Complexities of Modern Deployment and Hosting Solutions

Published on: Feb. 19, 2024
Last updated: Sep. 18, 2024

Written by:

Óscar Izquierdo
Óscar Izquierdo Valentín
DevOps
Sebastián Estrella

Subscribe to our blog

Join our community and get the latest articles, tips, and insights delivered straight to your inbox. Don’t miss it – subscribe now and be part of the conversation!
We care about your data. Check out our Privacy Policy.