Leanpub Header

Skip to main content

Infrastructure as Code for Security Engineers

Infrastructure as Code for Security Engineers
This book is 100% completeLast updated on 2026-08-19
Your infrastructure isn't a place anymore, it's text in a repo. This book teaches security engineers to read, review, and audit Terraform like an auditor, not a builder, so you know exactly what to look for before someone else's code hits production.
Free With Membership

With Membership

Free!

$4.99

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
About

About

About the Book

Infrastructure is no longer a place you visit. It's text in a repo. A single Terraform file can spin up a hundred servers, open a network to the internet, or hand a service the keys to a database, and the only record of it is a pull request merged on a Friday afternoon. That's moved a huge share of your attack surface into version control, and most security teams aren't reading it.

Infrastructure as Code for Security Engineers teaches security engineers, architects, and GRC/compliance professionals how to critically read, review, and audit Terraform, without becoming IaC authors themselves. It covers just enough of the mechanics to make you a competent reader, then focuses on the judgment: where secrets leak, why the state file is a liability, how to threat-model the pipeline, what policy-as-code can't guarantee, supply-chain risk in modules and providers, and how to turn a review into evidence an auditor will accept.

By the end, you should be able to sit down with someone else's infrastructure code under deadline and know exactly what to look for, what to ask, and what to refuse to sign off on.

Not for you if your goal is to become a Terraform practitioner. No coding background required.

Author

About the Author

Joshua Phillips

Cybersecurity engineer, developer, and security professional with experience spanning offensive security, penetration testing, red teaming, threat hunting, incident response, infrastructure automation, and software development. I began my technical career in the US Army before earning a degree in computer science and have spent my career building, defending, and breaking systems.

Contents

Table of Contents

Introduction

  1. Who this book is for
  2. Who this book is not for
  3. How to use this book
  4. Prerequisites

Chapter 1 — Why Security Engineers Can’t Ignore IaC

  1. The attack surface moved into the repo
  2. Why this is your problem specifically
  3. What this book will and won’t do

Chapter 2 — Reading Terraform Like an Auditor, Not a Builder

  1. The five things you need to recognize
  2. The plan is where the truth lives
  3. What you don’t need

Chapter 3 — Where Secrets Leak

  1. The hardcoded credential, and why it never really leaves
  2. Where secrets hide when they’re not “hardcoded”
  3. Provider credential scope: the leak that matters most
  4. Detecting what’s already leaked
  5. What this means for your review

Chapter 4 — The State File as a Liability

  1. Why the state file knows more than the code does
  2. Where state lives, and why that choice is a security decision
  3. What a stolen state file actually gives an attacker
  4. Drift as a security signal, not just a correctness problem
  5. What to check, in practice

Chapter 5 — Threat-Modeling the Pipeline

  1. An identity that never sleeps and never asks questions
  2. The access control layer moved to the merge button
  3. Compromise scenario: the poisoned pull request
  4. Compromise scenario: the runner itself
  5. Compromise scenario: the leaked pipeline token
  6. Mapping the pipeline to a threat model an auditor recognizes

Chapter 6 — Policy as Code: What It Can and Can’t Guarantee

  1. The landscape, briefly
  2. The failure mode: “the scanner passed”
  3. Reading a policy for what it actually enforces
  4. What good coverage looks like

Chapter 7 — Supply-Chain Risk in Modules and Providers

  1. What a module call actually commits you to
  2. Pinning is necessary and not sufficient
  3. Vetting a module before it gets copied a thousand times
  4. Providers: a different, sharper risk
  5. Dependency confusion and typosquatting, in IaC terms
  6. What to check, in practice

Chapter 8 — Reviewing a Terraform Plan Under Deadline

  1. The checklist
  2. Worked example
  3. What to demand, what to refuse
  4. Why this order works under pressure

Chapter 9 — Turning Review Into Evidence

  1. The audit trail you already have, if you use it
  2. Mapping what you’re already doing to what auditors ask for
  3. Documentation an auditor will actually accept
  4. From one review to a repeatable program

Appendix — Checklists, Commands, and References

  1. The under-deadline review checklist (Chapter 8)
  2. Secrets review checklist (Chapter 3)
  3. State file checklist (Chapter 4)
  4. Pipeline threat model (Chapter 5)
  5. Policy-as-code coverage checklist (Chapter 6)
  6. Supply-chain checklist (Chapter 7)
  7. Tool reference
  8. Core questions to carry into any review

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub