🔥Let’s Do DevOps: Writing Modular, Centralized, Custom Terraform GitHub Actions 🚀

Kyler Middleton
7 min readJun 22

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

Hey all!

Back in the Azure DevOps (ADO) days, I grew our terraform pipelines from a single POC to several hundred. Around about 40 pipelines I got really annoyed updating each pipeline with the innovations I was creating, and decided to start templating them out. On ADO that was incredibly easy — you could reference even single steps in a file, and they’d be pulled into the template — it worked amazingly.

Things aren’t as easy over at GitHub, but they can also be made to work well!

As part of this project, I was maintaining almost a dozen pipelines across a half dozen repos, and every time I’d come up with an innovation or bug-fix, I’d have to roll it out everywhere — but no longer! I implemented centralized Actions that I wrote, that each repo in our Organization can reference, and now I make changes in one place.

Let’s talk about Reusable Workflows, which I didn’t use here, and why.

If you want to skip right to the code, scroll all the way to the bottom for the GitHub Repo link! 🚀 🥳

Way Easier: Reusable Workflows

GitHub’s newest innovation to permit easily sharing Actions among many repos is called a Reusable Workflow. This permits a Job (not a Step) to call another Action, and have it run and track it. I explored this pretty thoroughly in this story:

It works great! However, note what I said in brackets above — it must be called as a Job, not as a Step. So if we want to call the Action lots of times in a matrix pattern (super common and effective for Terraform Validation, in my experience), we can set all the permutated variables in the include block.

Kyler Middleton

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