Member-only story

Building a really simple GitHub Actions CI ‘workflow’ to validate Terraform code

Colin But
FAUN — Developer Community 🐾
4 min readSep 26, 2024

In this short story i am going to show you exactly how you can easily construct a really simple CI (Continuous Integration) ‘workflow’ as part of your DevOps workflows to validate your infrastructure Terraform code when you merge in Terraform code to your GitHub code repository.

TL:DR

If you just want me to show you the full snippet code here it is.

*but i do encourage you to read on and see my explanations of each step in terms of what it is actually doing and why we are doing it. It is important to understand the code you write and not rely on CPD (Copy & Paste Development)^.

^another thing for another day…

name: PR Build

on:
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
container: colinbut/terraform-build-container:1.0.0
steps:
- name: checkout
uses: actions/checkout@v3

- name: terraform validate
run: terraform validate

- name: run tflint
run: tflint terraform

- name: run tfsec
run: tfsec .

What does the code do?

Okay, so what does the code do then?

--

--

Published in FAUN — Developer Community 🐾

We help developers learn and grow by keeping them up with what matters. 👉 www.faun.dev

Written by Colin But

Writer sharing thoughts on pretty much everything. P.S. I’m a Coffee-Addict ☕ You can support me by buying me a coffee: https://bit.ly/3hQ5M63

No responses yet

What are your thoughts?