samwise-CLI: The Open Source Terraform module dependency tracker
Dev
Posted on August 12, 2024
Terraform
Terraform is an Infrastructure-as-Code(IaC) tool that is written in Hashicorp Configuration Language(HCL). This article assumes that the reader has worked with Terraform and understand how modules work.
Everyone coding in Terraform has either created their own modules, or at least used someone else's.
Terraform modules
Modules are containers for multiple resources that are used together. A module consists of a collection of .tf and/or .tf.json files kept together in a directory.
Modules are the main way to package and reuse resource configurations with Terraform.
Modules can be published to registries like Terraform registry or GitLab. Modules can also be served from Git repositories by providing the HTTPS or SSH URLs. These can be versioned as well. For example,
As your repositories grow and you reference your modules in other repositories, you would reasonably version your modules to ensure that upstream changes in the source doesn't break your infrastructure. However, it is difficult to keep track of all the new releases for the modules being used and even harder to do it regularly. Unaddressed, this builds overtime as tech debt as one day you discover that a core module is now 3 major versions ahead.
Solution
Presenting samwise-cli, a tool to help track your repository's Terraform/OpenTofu dependencies upstream. Searches your repository for usages of modules and generates a report of the modules that have updates available along with all the versions that are more advanced than the version used currently.
At the moment, there's only one command, but hopefully there'll be more soon as the tool develops.
A CLI application to accompany on your terraform module journey and sharing your burden of module dependency updates, just as one brave Hobbit helped Frodo carry his :)
samwise
A CLI application to accompany on your terraform module journey and sharing your burden of module dependency updates, just as one brave Hobbit helped Frodo carry his :)
For this to run where modules are using private GitHub repositories, .samwise.yaml config file needs to passed as an argument or needs to be present at the user's home directory.