Skip to content
EgyKode
04 · Infrastructure as CodeLab 28 / 59
Guided labterraform

Terraform Validation, Linting & CI

Build the gate that runs before every apply: format, validate, lint, scan, and a plan a human approves.

Time
50 min
Level
Intermediate
Objectives
4 objectives
Cost
Free

Where this fits in the platform

Already built

This lab adds

  • A plan that runs in CI, so drift is caught before apply

Which lets you

Before you start

You will need

  • Terraform >= 1.6
  • tflint
  • trivy or checkov
  • A GitHub repository

You do not need these already — the lab environment below provides them.

You will be able to

  • Chain the checks that catch a bad change before it reaches AWS
  • Apply exactly the plan that was reviewed
  • Detect drift on a schedule rather than during an incident

CostFree

— everything here runs without creating infrastructure. `plan` reads AWS but changes nothing.

Nothing to pay in the browser. Open the terminal runs this against a simulated cloud — the same API calls and the same commands, with no account and no bill. The figure above applies only if you build it in your own.

The scenario#

Terraform runs from someone's laptop. Reviews read the HCL, not the plan, so nobody notices the -/+ that would recreate the database until it happens.

This lab puts the checks in front of the apply.

Hands-on environment

Run this lab in a real terminal, free and in your browser. The environment is temporary and yours alone — break it as much as you like.

Open the terminal

Opens in Killercoda, in a new tab — keep this page open for the steps.

Run it on your own machine

Run this lab on your own machine. One command starts the environment, with everything the lab needs already installed:

You will need:

  • terraform
  • docker
git clone https://github.com/EgyKode/EgyKode-lab.git
cd EgyKode-lab
./egykode start
./egykode shell

You need Docker and Git installed. Everything else runs inside the environment. The first start downloads it and takes a few minutes; later starts are seconds.

Not sure what you already have? Run: npm run doctor — it checks and changes nothing.

Anything you tick here is your own record. EgyKode cannot see inside that terminal, so the success criteria stay self-assessed even when the environment checks your work for you.

The local checks

Step 1 of 6

The order, and why#

text
fmt  →  validate  →  tflint  →  security scan  →  plan  →  review  →  apply

Cheapest first. fmt takes a second; a security scan takes twenty; plan calls AWS. Failing early means the expensive steps only run on changes that deserve them.

Success criteria

0 of 4

The concept behind it

Ready to try it without help?Do the challenge

Phase complete · 04 Infrastructure as Code

You can now: The AWS environment is described in version-controlled modules with remote, locked state.

Next phase

Lab 28 of 59 on the project path

05 · Configuration managementAnsible Architecture, Configuration & Automated InventoryHave Ansible discover your EC2 instances by tag instead of maintaining a host list nobody remembers to update.39 minIntermediate

Previous: Jenkins EC2 Instance, S3 Backend & AWS Backup Vault