SlideShare a Scribd company logo
1
Jay Wallace, Production Engineering
Feb 20th, 2020
Twitter: @mootpt
Terraform Code Reviews:
Supercharged with Conftest
HashiTalks
2
Morning
Routine
HashiTalks
3
What we will cover
Typical Evolution of Terraform
Conftest
Easy Recipes For Success
Demo In Practice
OUTLINE
4
Typical Evolution of
Terraform
HashiTalks
Works on my machine
5
Looks good to me 🤖🤖🤖🤖
Evolution broken into 3 eras
HashiTalks
6
Agility vs
Stability
Agility
Stability
HashiTalks
7
Agility vs
Stability
Stability
Agility
Help Wanted
HashiTalks
8
Write some code
Works on
my
machine
HashiTalks
Apply locally
Works on
my
machine
9
HashiTalks
Uh Oh. Someone already
created the resource
Works on
my
machine
10
HashiTalks
11
This is a simple fix. We will just add remote
state and it won’t happen again.
HashiTalks
Resource was created, but
it’s not in our config
Works on
my
machine
12
HashiTalks
13
Works on my machine
Make Changes Quick
Engineers can just ship.
Terraform apply is easy to just
run.
Nothing to implement
Outside configuring state
buckets, there isn’t much work
on the frontend.
State & Config inconsistent
There is a chance engineers
running Terraform
independently will run into some
config/state drift.
High Risk
Engineers may inadvertently
introduce security risks. Also,
possibly destroy production
resources.
No Accountability
No audit trail of who did what
and when. Little to no
collaboration
HashiTalks
Agility vs
Stability
Stability
Agility
Help Wanted
Startup Mode
14
HashiTalks
15
All of this should be happening in version
control. That’ll fix it!
HashiTalks
16
Atlantis
Terraform Pull Request Automation
HashiTalks
17
Engineer writes some code
LGTM
HashiTalks
Pushes to GitHub.
LGTM
18
HashiTalks
Explains what they are
doing
LGTM
19
HashiTalks
20
Atlantis runs the plan
instead of the engineer
LGTM
HashiTalks
21
Requests an approval
before an apply can occur
LGTM
HashiTalks
22
Comments in GitHub to
trigger Atlantis to run apply
LGTM
HashiTalks
23
Looks good to me
Collaborative
Engineers able to collaborate
effectively. Allows for code
review and approval process
Auditable and Accountable
Clear change logs and the
ability to know who did what
and when.
Bottlenecks
More code reviews equates to
more engineering hours. Adds
up the more infrastructure you
manage.
Config reflects state
No more developers operating
on their own machine. Code is
accurate reflection of state of
world
HashiTalks
24
Agility vs
Stability
Stability
Agility
Help Wanted
Startup Mode
Slow and Steady
HashiTalks
25
Now I’m a full-time Pull Request reviewer.
How can I automate this?
26
Conftest
HashiTalks
27
These (policies) are the things were actually looking for when we
do code reviews. We should be checking for violations before
there is ever a human involved.
Policy Enforcement
HashiTalks
28
OPA is an engine that
enables a single approach
for policy enforcement
across different services
Conftest
HashiTalks
29
Built on top of OPA. With a
focus on testing data
Conftest
HashiTalks
30
Conftest
Purposeful Design
Designed specifically to be used
with CI or local testing.
Functionally same as OPA.
Works well with Atlantis
Not just HCL/Terraform
OPA supports a wide variety of
structured data, today we are
just talking about testing
Terraform
Everything is Rego
DSL for making policy
assertions on the given
structured data. Rego
playground awesome place to
experiment
HashiTalks
Conftest functionality
geared towards user
Conftest
31
HashiTalks
For us it started small.
Conftest
32
HashiTalks
Example policy execution
Conftest
33
HashiTalks
Example policy checking if
our security groups are too
open.
Conftest
34
HashiTalks
35
Great. How do I run this in my pipelines?
HashiTalks
GitHub Actions
36
There is a GitHub action for contest CircleCI has a conftest orb
Traditional CI
Atlantis is a great fit
GitOps
37
Recipes for Success
HashiTalks
38
Recipe 1: Resource whitelisting
HashiTalks
Do we care about this
resource?
Recipe 1
39
HashiTalks
40
Recipe 2: Approved Modules
HashiTalks
Is the module approved?
Recipe 2
41
HashiTalks
42
Recipe 3: CRUD
HashiTalks
Is this engineer about to
delete a bunch of
resources?
Recipe 3
43
44
Example setup
HashiTalks
Atlantis + Custom Workflow
45
Execute Terraform and Conftest Pul; Request mergeable
GitHub Status Checks
Determining approvers
PullApprove
Our setup
HashiTalks
Note the custom conftest
workflow
atlantis
46
HashiTalks
We both run conftest in this
scripts and update GitHub
with custom statuses
opa.sh
47
HashiTalks
We use this service over
CODEOWNERS as it
supports conditional
approvals on custom
statuses
pullapprove
48
49
Demo - Approved
Modules
HashiTalks
50
Conftest
Agility
With automated testing
engineers can move faster
without approvals
Auditable and Accountable
Clear change logs and the
ability to know who did what
and when.
More work on frontend
Implementing some initial
policies and a workflows around
conftest takes some work
Reliability
By codifying our policies, we
can feel confident on what can
and can’t slip into our codebase
HashiTalks
51
Agility vs
Stability
Stability
Agility
Help Wanted
Startup Mode
Slow and Steady
Supercharged
52
Photo by Laura Johnston on Unsplash
Thank you

More Related Content

PPTX
もしSIerのエンジニアがSRE本を読んだら
PDF
ABEMA を次のフェーズへ進化させる技術への取り組み
PDF
20210127 今日から始めるイベントドリブンアーキテクチャ AWS Expert Online #13
PDF
IPv6って何?(拡張ヘッダ編)
PDF
XML-RPC : Pythonが「電池付属」と呼ばれる理由
PDF
Ansible tower 構築方法と使い方
PDF
はじめてのグラフデータベース 〜 Amazon Neptune と主なユースケース 〜
PPTX
大規模データ処理の定番OSS Hadoop / Spark 最新動向 - 2021秋 -(db tech showcase 2021 / ONLINE 発...
もしSIerのエンジニアがSRE本を読んだら
ABEMA を次のフェーズへ進化させる技術への取り組み
20210127 今日から始めるイベントドリブンアーキテクチャ AWS Expert Online #13
IPv6って何?(拡張ヘッダ編)
XML-RPC : Pythonが「電池付属」と呼ばれる理由
Ansible tower 構築方法と使い方
はじめてのグラフデータベース 〜 Amazon Neptune と主なユースケース 〜
大規模データ処理の定番OSS Hadoop / Spark 最新動向 - 2021秋 -(db tech showcase 2021 / ONLINE 発...

What's hot (20)

PDF
Redmineをちょっと便利に! プログラミング無しで使ってみるREST API
PPTX
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
PDF
ヤフーの広告レポートシステムをSpring Cloud Stream化するまで #jjug_ccc #ccc_a4
PDF
Yahoo!ニュースにおけるBFFパフォーマンスチューニング事例
PDF
オラクルのHadoopソリューションご紹介
PDF
詳説WebAssembly
PDF
IIJ Technical DAY 2019 ~ IIJのサーバインフラはここまでやっています
 
PDF
ホットな日本語入力技術のお勉強。〜 OSC 2016 Hamanako 編 〜
PDF
「これからはじめるNGINX技術解説~基本編」セミナー (NGINX Back to Basic in JP)
PDF
HBaseとRedisを使った100億超/日メッセージを処理するLINEのストレージ
PDF
【BS4】時は来たれり。今こそ .NET 6 へ移行する時。
PPTX
検索サービス開発が絶対におもしろいと思う理由
PDF
/etc/network/interfaces について
PDF
今Serverlessが面白いわけ
PDF
Apache OpenWhiskで実現するプライベートFaaS環境 #tjdev
PDF
イマドキのExcelスクショの撮り方
PPTX
Takalab 勉強会#01 - Kali Linux 環境構築
PDF
ACRiウェビナー:小野様ご講演資料
PDF
2021 10-07 kdd2021読み会 uc phrase
PDF
私たちはRESTCONFでネットワーク自動化的に何が嬉しくなるのか考えてみた
Redmineをちょっと便利に! プログラミング無しで使ってみるREST API
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
ヤフーの広告レポートシステムをSpring Cloud Stream化するまで #jjug_ccc #ccc_a4
Yahoo!ニュースにおけるBFFパフォーマンスチューニング事例
オラクルのHadoopソリューションご紹介
詳説WebAssembly
IIJ Technical DAY 2019 ~ IIJのサーバインフラはここまでやっています
 
ホットな日本語入力技術のお勉強。〜 OSC 2016 Hamanako 編 〜
「これからはじめるNGINX技術解説~基本編」セミナー (NGINX Back to Basic in JP)
HBaseとRedisを使った100億超/日メッセージを処理するLINEのストレージ
【BS4】時は来たれり。今こそ .NET 6 へ移行する時。
検索サービス開発が絶対におもしろいと思う理由
/etc/network/interfaces について
今Serverlessが面白いわけ
Apache OpenWhiskで実現するプライベートFaaS環境 #tjdev
イマドキのExcelスクショの撮り方
Takalab 勉強会#01 - Kali Linux 環境構築
ACRiウェビナー:小野様ご講演資料
2021 10-07 kdd2021読み会 uc phrase
私たちはRESTCONFでネットワーク自動化的に何が嬉しくなるのか考えてみた
Ad

Similar to Terraform Code Reviews: Supercharged with Conftest (20)

PDF
OracleBeer_Terraform_soe.pdf
PDF
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
PDF
Terraform-2.pdf
PDF
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
PPTX
Hashiconf Israel 2022 - Terraform Pull Request Automation.pptx
PDF
Self-service PR-based Terraform
PPTX
Git,github & terraform Basics: Introduction
PDF
My Hashitalk Indonesia April 2024 Presentation
PDF
Best Practices of Infrastructure as Code with Terraform
PPTX
Terraform: Tales from the Trenches
PDF
DevOps Braga #9: Introdução ao Terraform
PDF
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
PDF
Head in the Clouds: Testing Infra as Code - Config Management 2020
PDF
Terraform GitOps on Codefresh
PPTX
Autopilot, but never let go of the wheel
PPTX
Terraform in production - experiences, best practices and deep dive- Piotr Ki...
PDF
The hitchhiker's guide to terraform your infrastructure
PDF
GDG Cloud Southlake #8 Steve Cravens: Infrastructure as-Code (IaC) in 2022: ...
PDF
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
PDF
DevOps Fest 2020. immutable infrastructure as code. True story.
OracleBeer_Terraform_soe.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Terraform-2.pdf
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
Hashiconf Israel 2022 - Terraform Pull Request Automation.pptx
Self-service PR-based Terraform
Git,github & terraform Basics: Introduction
My Hashitalk Indonesia April 2024 Presentation
Best Practices of Infrastructure as Code with Terraform
Terraform: Tales from the Trenches
DevOps Braga #9: Introdução ao Terraform
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Head in the Clouds: Testing Infra as Code - Config Management 2020
Terraform GitOps on Codefresh
Autopilot, but never let go of the wheel
Terraform in production - experiences, best practices and deep dive- Piotr Ki...
The hitchhiker's guide to terraform your infrastructure
GDG Cloud Southlake #8 Steve Cravens: Infrastructure as-Code (IaC) in 2022: ...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
DevOps Fest 2020. immutable infrastructure as code. True story.
Ad

Recently uploaded (20)

PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
DOCX
Unit-3 cyber security network security of internet system
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PDF
SASE Traffic Flow - ZTNA Connector-1.pdf
PDF
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
PPT
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PDF
RPKI Status Update, presented by Makito Lay at IDNOG 10
PDF
Testing WebRTC applications at scale.pdf
PPTX
presentation_pfe-universite-molay-seltan.pptx
PPTX
Internet___Basics___Styled_ presentation
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PDF
Introduction to the IoT system, how the IoT system works
PPTX
Introuction about ICD -10 and ICD-11 PPT.pptx
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PDF
WebRTC in SignalWire - troubleshooting media negotiation
PPTX
SAP Ariba Sourcing PPT for learning material
PPTX
international classification of diseases ICD-10 review PPT.pptx
INTERNET------BASICS-------UPDATED PPT PRESENTATION
Unit-3 cyber security network security of internet system
An introduction to the IFRS (ISSB) Stndards.pdf
SASE Traffic Flow - ZTNA Connector-1.pdf
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
RPKI Status Update, presented by Makito Lay at IDNOG 10
Testing WebRTC applications at scale.pdf
presentation_pfe-universite-molay-seltan.pptx
Internet___Basics___Styled_ presentation
Cloud-Scale Log Monitoring _ Datadog.pdf
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
Introduction to the IoT system, how the IoT system works
Introuction about ICD -10 and ICD-11 PPT.pptx
Job_Card_System_Styled_lorem_ipsum_.pptx
Unit-1 introduction to cyber security discuss about how to secure a system
WebRTC in SignalWire - troubleshooting media negotiation
SAP Ariba Sourcing PPT for learning material
international classification of diseases ICD-10 review PPT.pptx

Terraform Code Reviews: Supercharged with Conftest