🔥Let’s Do DevOps: Using the Tofu/Terraform AzApi Provider to Find All the Subnets Everywhere!🚀

Kyler Middleton
7 min readJun 4, 2024

This blog series focuses on presenting complex DevOps projects as simple and approachable via plain language and lots of pictures. You can do it!

A note as we start — I’ve always been an open source kid, and I’ll continue to be so. To reflect that, I’ll be using OpenTofu/Tofu primarily, rather than Terraform, which is now not an open source tool due to a relicensing by Hashicorp. That said, at this point all the code I’ll share will work on both platform exactly the same. Let me know if you want to hear me expand on why I’ve made this decision or other topics here.

Also! If you prefer video to reading, I gave this article as a talk here: https://www.youtube.com/watch?v=THbB8tLJRPY

Hey all!

I’ve had a series of projects recently that I’ve historically told folks that “sorry, tofu can’t do that,” and as my skills have expanded I’ve found other ways to do so. One example is to find all the subnets within an entire Azure subscription and get all their GUIDs. Another is to find all the VMs matching a name pattern and then grab their primary private IP to put into a list.

Tofu is capable of doing all this when it’s in the same terraform state, or when it has exact information about what it’s looking up, like how many servers to find, and their exact names, and that the resource group they live in exists. If any of that information is incomplete (like, of…

--

--

Kyler Middleton

DevNetSecOps, DevRel, cloud security chick. I will teach you, it’s unavoidable. She/Her 🏳️‍🌈🏳️‍🌈, INFJ-A, support the EFF!