samwise-CLI: The Open Source Terraform module dependency tracker

PHPz
Release: 2024-08-12 18:36:12
Original
718 people have browsed it

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,

module "consul" { source = "github.com/hashicorp/example" }
Copy after login

Versioned:

module "consul" { source = "github.com/hashicorp/example?ref=1.2.6" }
Copy after login

Challenge

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.

samwise-CLI: The Open Source Terraform module dependency tracker

At the moment, there's only one command, but hopefully there'll be more soon as the tool develops.

Random repo for the time being

samwise-CLI: The Open Source Terraform module dependency trackerDarth-Tech / samwise-cli

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 :)

samwise-CLI: The Open Source Terraform module dependency tracker

%,( "' /%% / Cccc' (cause I couldn't find good enough Samwise Gamgee ASCII art) Frodo by Shanaka Dias">
\ : / '-: __ :-' -: )(_ :-- -' |r-_i'- ,sSSSSs, (2-,7 sS';:'`Ss )-j ;K e (e s7 / ( S, '' SJ ( ;/ sL_~~_;(S_) _7 |, 'J)_.-' />'-' `Z j J /-;-A'-'|'--'-j\ L L ) |/ : / \ \ \ | | | '._.'| L \ \ | | | | \ J \ \ _/ | | | ',| \ L.,' | | | | |/ _;-r-<_.| \=\ __.; _/ {_}" L-' '--' / /| | , | \| | | | ") L ;| | /| /| ; | / | | | ; | ) | | | ;| | / | | ;| || | | | L-'|____|| )/ | % %/ '-,-
Copy after login
View on GitHub

checkForUpdates

samwise-CLI: The Open Source Terraform module dependency tracker

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.

.samwise.yaml format:

github_key: github_username:
Copy after login

Currently only GitHub HTTPS authentication is supported but SSH authentication will be supported soon.

Result

CSV Format
samwise-CLI: The Open Source Terraform module dependency tracker

JSON Format
samwise-CLI: The Open Source Terraform module dependency tracker

Limitations(or better described as features to be added)

  • SSH authentication for retrieving module sources
  • Tracking Hashicorp's registry's module(they have an API to list versions here

Context for the name

I love Lord of the Rings :)

The above is the detailed content of samwise-CLI: The Open Source Terraform module dependency tracker. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Previous article:Go Programming | String Basics | Character Encoding Next article:GORM, PostgreSQL & Atlas
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Latest Issues
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!