SlideShare a Scribd company logo
How to scale with Terraform
Equipe Meetup
Julien Bichon
Community ambassador
@jubichon
+ Talk 1 - How to scale with
Terraform - Mehdi Laruelle
+ Talk 2 - Déployer Prometheus +
Thanos avec Terraform dans
kubernetes - Thierry Sallé
HashiCorp User Group LYON
+ Depuis juin 2019
+ 120 membres
+ 2 meetups
+ 5 HUG en France
+ Paris
+ Toulouse
+ Nice
+ Nantes
+ Lyon
Thank you
Mehdi LARUELLE
@D2SI
Hashicorp Terraform:
How to scale
D2SI Me
Mehdi LARUELLE
Consultant Cloud &
Automation
@mehdilaruelle
Whoami ?
Christophe Gasmi
Consultant Cloud &
Kubernetes chez D2SI
@RekCaH_fr
The force will be
always with you
PROGRAMME
1 Terraform ? Community ?
2 One for all
3 All for one
4 What next ?
// Terraform intro1
How to scale with Terraform
Opensource
Providers
HCL
Multi providers usage in HCL
Plugins & more
// One for all2
Stack App
Organization
AppApp App
App BackendApp Backend App Backend
DEV RE7PROD
App Frontend App FrontendApp Frontend
Isolation
Folder
Variable
maps
Tfvars
Tfvars +
maps
Divergence
Complexific
ation
Solution ?
Best for
multi region
Starting point
Root
Base
Infra
Apps As an Ops, I need
to update my EC2
instance
As a Dev, I need
to update my app
Example with one region
Example with multiple regions
Example with multiple regions
Modularity ?
Functional usage Documentation Test
Reusable and standard
Module
module name : kms
variables.tfmain.tf
module name : kms
Module: best practices
1. No big module
2. No module-inception
3. Have a nice variables naming and description
4. Define a minimal provider & Terraform version
a. terraform { required_version = "< 0.12.0" }
b. terraform { required_providers { aws = ">= 2.6.0" } }
5. Have an output defined by a ressource
Ex:
aws_vpc.default.id => vpc_id
aws_subnet.private.*.id => private_subnets_id
aws_subnet.private.*.id => private_subnets
Module around the world
Documentation
● Automation:
○ terraform-docs
○ pre-commit-terraform
○ CI
● Examples:
○ Make multiple cases
○ Test it with CI (terraform fmt, check, validate,
terraform-kitchen)
To Terraform or not to Terraform
Strongly coupled:
Advantage :
Reusable resources & less
static values
Disadvantage :
● Not always have access read only
to the tfstate by another team
● Can be difficult to reuse Terraform
output from another tool
Loosely coupled:
Advantage :
No Terraform dependencies
Disadvantage :
● A resource do not have always a
data source
● Infrastructure state can shift without
knowing
Strongly coupled
local computer webapp
vpc
terraform.tfstate
terraform.tfstate
main.tf
webapp
vpc
main.tf
my-bucket-tfstate
Strongly coupled
local computer
my-bucket-tfstate
webapp
vpc
terraform.tfstate
terraform.tfstate
main.tf
webapp
vpc
main.tf
data.terraform_remote_state.rs-vpc.subnets_private
Loosely coupled
local computer webapp
vpc
terraform.tfstate
terraform.tfstate
main.tf
webapp
vpc
main.tf
my-bucket-tfstate
// All for one3
All for the best in the best of all worlds
Ops
In real world
Ops1
Ops2
Problems:
● No lock
● Local state
● Terraform file can
be variant
With CI/CD
1. Push IaC
2. CI/CD
process use
Terraform
Ops
Tfstate Lock
CI/CD example (Christophe G.)
1.1 Create branch
from develop
1.2. Hook pre-
commit
1.3. Commit code
1.4. Push code
3. Terraform apply
in Feature Env
Ops
Reviewers
4. Infrastructure/Apps
Tests
2. Open Merge
Request
automatically
5. Merge Request
Review
CI/CD example (Christophe G.)
9a. Terraform
plan in Dev Env
Reviewers
9b. Terraform apply in
Dev Env (Manual)
8. Open Merge
Request
automatically
10. Merge Request
Review
7. Pipeline run in
develop branch
CI/CD example (Christophe G.)
14. Terraform plan
in Staging Env
Ops & Reviewers
15. Terraform apply in
Staging Env (Manual)
16. Tests
Infra/Apps
12. Pipeline run in
master branch
17. Auto Tag
Branch master
18. Terraform plan
in Prod Env
19. Terraform apply in
Prod Env (Manual)
● Analyse terraform plan
● Start the terraform apply job
20a. Tests
Infra/Apps20b.
Rollback if
fail
What about the flow ?
Master
(prod)
Develop
Feature
V0.1 V1.0
// To infinity and
// beyond
4
The last but not the least
● Always return an empty list in your output at least
resource "aws_subnets" "public" {
count = "${var.subnets_public_enabled ? length(var.subnets_public) : 0}"
vpc_id = aws_vpc.main.id
cidr_block = element(var.subnets_public, count.index)
# ... arguments omitted
}
output "public_subnets" {
description = "The subnet IDs for public network"
value = "${concat(aws_subnets.public.*.id, list(""))}"
}
The last but not the least
Define a
commun
separator
Write in
lowercase
resource "aws_eip" "public" {}
resource "aws_eip" "public_eip" {}
resource "aws_eip" "public_aws_eip" {}
resource "aws_eip" "gitlab_public" {}
resource "aws_eip" "gitlab-public" {}
Or
Best
Practice
CI/CD
The last but not the least
Make your
own TF
image
(providers
included)
Module as
artefact or
cache (each
steps)
TF_IN_AUTOMATION
Use
variables
and
datasource
Tagging:
● Projet
● Env
● Namespace
● terraform_state_bucket
● terraform_state_key
● terraform_git_repo
Keep It
Simple
Stupid
Module
everywhere
Never apply
yourself, let
the CI do it
Documentat
ion can be
obfuscated
Force your
providers &
TF versions
Update
frequently
providers &
TF
Questions ?

More Related Content

PPTX
Talk be secret like a ninja with Vault
PDF
Jaringan, Linux, Docker
PDF
Terraform 101
PDF
Discovering Docker Volume Plugins and Apps using VirtualBox
PDF
XFLTReat: a new dimension in tunnelling
PPTX
Dock ir incident response in a containerized, immutable, continually deploy...
PDF
Scaling i/o bound Microservices
PDF
OpenShift – the open-source PaaS by Marek Jelen
Talk be secret like a ninja with Vault
Jaringan, Linux, Docker
Terraform 101
Discovering Docker Volume Plugins and Apps using VirtualBox
XFLTReat: a new dimension in tunnelling
Dock ir incident response in a containerized, immutable, continually deploy...
Scaling i/o bound Microservices
OpenShift – the open-source PaaS by Marek Jelen

What's hot (18)

PDF
Discovering Volume Plugins with Applications using Docker Toolbox and VirtualBox
PDF
Docker Summit 2016 - Kubernetes: Sweets and Bitters
PDF
EC2 Storage for Docker 150526b
PDF
Open shift intro for Philly PUG
PDF
Modern Monitoring [ with Prometheus ]
PDF
Writing Rust Command Line Applications
PDF
Rancher 2.0 Technical Deep Dive
PDF
Puppet Camp Sydney 2015: Puppet and AWS is easy right.....?
PDF
JupyterHub + kubernetes
PPT
ApacheCon NA 2011 report
PDF
Fluentd and PHP
PDF
DockerDay2015: Docker Networking
PPTX
More tips and tricks for running containers like a pro - Rancher Online MEetu...
PPTX
Running Rancher and Docker on Dev Machines - Rancher Online Meetup - May 2016
PDF
Behind the scenes with Docker volume plugins
PDF
PyCon UK - iCE: Interactive cloud experimentation
PPT
Introduction to Git Commands and Concepts
ODP
Lightcycle
Discovering Volume Plugins with Applications using Docker Toolbox and VirtualBox
Docker Summit 2016 - Kubernetes: Sweets and Bitters
EC2 Storage for Docker 150526b
Open shift intro for Philly PUG
Modern Monitoring [ with Prometheus ]
Writing Rust Command Line Applications
Rancher 2.0 Technical Deep Dive
Puppet Camp Sydney 2015: Puppet and AWS is easy right.....?
JupyterHub + kubernetes
ApacheCon NA 2011 report
Fluentd and PHP
DockerDay2015: Docker Networking
More tips and tricks for running containers like a pro - Rancher Online MEetu...
Running Rancher and Docker on Dev Machines - Rancher Online Meetup - May 2016
Behind the scenes with Docker volume plugins
PyCon UK - iCE: Interactive cloud experimentation
Introduction to Git Commands and Concepts
Lightcycle
Ad

Similar to How to scale with Terraform (20)

PDF
The hitchhiker's guide to terraform your infrastructure (hashiconf)
PDF
Git ops & Continuous Infrastructure with terra*
PDF
The hitchhiker's guide to terraform your infrastructure
PDF
Terraform in Depth (MEAP V01) Robert Hafner
PDF
Terraform in Depth (MEAP V01) Robert Hafner
PDF
Managing GCP Projects with Terraform (devfest Pisa 2018)
PDF
My Hashitalk Indonesia April 2024 Presentation
PDF
Instant download Terraform in Depth (MEAP V01) Robert Hafner pdf all chapter
PDF
Terraforming
PPTX
Terraform: Tales from the Trenches
PDF
20221130 - Luxembourg HUG Meetup
PDF
اسلاید اول جلسه دوم کلاس پایتون برای هکرهای قانونی
PPTX
Tackling Terraform at Ticketmaster
PDF
English - Lauching a Public PaaS on Open Source Getup & OpenShift Origin - FI...
PPTX
Terraform Best Practices for Infrastructure Scaling
PDF
CNCF_ A step to step guide to platforming your delivery setup.pdf
PPTX
Introduction to Docker
PPTX
FLUTTER DHRUVIK.pptx
PDF
Terraform Best Practices - DevOps Unicorns 2019
PDF
Collaborative Terraform with Atlantis
The hitchhiker's guide to terraform your infrastructure (hashiconf)
Git ops & Continuous Infrastructure with terra*
The hitchhiker's guide to terraform your infrastructure
Terraform in Depth (MEAP V01) Robert Hafner
Terraform in Depth (MEAP V01) Robert Hafner
Managing GCP Projects with Terraform (devfest Pisa 2018)
My Hashitalk Indonesia April 2024 Presentation
Instant download Terraform in Depth (MEAP V01) Robert Hafner pdf all chapter
Terraforming
Terraform: Tales from the Trenches
20221130 - Luxembourg HUG Meetup
اسلاید اول جلسه دوم کلاس پایتون برای هکرهای قانونی
Tackling Terraform at Ticketmaster
English - Lauching a Public PaaS on Open Source Getup & OpenShift Origin - FI...
Terraform Best Practices for Infrastructure Scaling
CNCF_ A step to step guide to platforming your delivery setup.pdf
Introduction to Docker
FLUTTER DHRUVIK.pptx
Terraform Best Practices - DevOps Unicorns 2019
Collaborative Terraform with Atlantis
Ad

More from Devoteam Revolve (20)

PPTX
Formations AWS - Catalogue D2SI Authorized Training Partner
PDF
Meetup Sécurité - AWS - Boundary Policy
PDF
Meetup Sécurité - AWS - Recap Reinforce 2019
PPTX
Meetup Sobriété numérique
PPTX
La DSI plateforme : DevOps, Agilité et Cloud
PPTX
Sécurité via l'automatisation : DevOps pour InfoSec. chez Renault Digital - A...
PPTX
Scaling @Bouygues Telecom AWS Paris 2019
PPTX
Entreprise Plateforme - Le nouveau modèle ?
PPTX
A way to share secrets in your pipeline - Hashidays 2018
PPTX
Transformation Cloud & DevOps chez Renault Digital - AWS Summit Paris 2018
PPTX
Automation of Active Directory's Deployments on AWS
PPTX
AWS Summit Paris 2017 : DevOps in a container world
PPTX
AWS Summit Paris 2017 : AWS loves Microsoft Workloads
PPTX
AWS Summit Paris 2017 : Gameday Veolia
PPTX
Meetup Responsive Org #1
PPTX
Continuous integration of_puppet_code
PPTX
Réunion de triage en holacratie v2
PPTX
[Oldies] Club client D2SI : DevOps
PPTX
Présentation D2SI AWS Summit Paris 2014
PDF
Achieving Continuous Delivery with Puppet
Formations AWS - Catalogue D2SI Authorized Training Partner
Meetup Sécurité - AWS - Boundary Policy
Meetup Sécurité - AWS - Recap Reinforce 2019
Meetup Sobriété numérique
La DSI plateforme : DevOps, Agilité et Cloud
Sécurité via l'automatisation : DevOps pour InfoSec. chez Renault Digital - A...
Scaling @Bouygues Telecom AWS Paris 2019
Entreprise Plateforme - Le nouveau modèle ?
A way to share secrets in your pipeline - Hashidays 2018
Transformation Cloud & DevOps chez Renault Digital - AWS Summit Paris 2018
Automation of Active Directory's Deployments on AWS
AWS Summit Paris 2017 : DevOps in a container world
AWS Summit Paris 2017 : AWS loves Microsoft Workloads
AWS Summit Paris 2017 : Gameday Veolia
Meetup Responsive Org #1
Continuous integration of_puppet_code
Réunion de triage en holacratie v2
[Oldies] Club client D2SI : DevOps
Présentation D2SI AWS Summit Paris 2014
Achieving Continuous Delivery with Puppet

Recently uploaded (20)

PDF
August Patch Tuesday
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
PPTX
The various Industrial Revolutions .pptx
PDF
project resource management chapter-09.pdf
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Architecture types and enterprise applications.pdf
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PPTX
observCloud-Native Containerability and monitoring.pptx
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
Hybrid model detection and classification of lung cancer
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PPTX
1. Introduction to Computer Programming.pptx
PPTX
O2C Customer Invoices to Receipt V15A.pptx
August Patch Tuesday
Getting started with AI Agents and Multi-Agent Systems
A contest of sentiment analysis: k-nearest neighbor versus neural network
WOOl fibre morphology and structure.pdf for textiles
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
DP Operators-handbook-extract for the Mautical Institute
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
The various Industrial Revolutions .pptx
project resource management chapter-09.pdf
Zenith AI: Advanced Artificial Intelligence
Architecture types and enterprise applications.pdf
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
observCloud-Native Containerability and monitoring.pptx
Final SEM Unit 1 for mit wpu at pune .pptx
Hybrid model detection and classification of lung cancer
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
1 - Historical Antecedents, Social Consideration.pdf
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
1. Introduction to Computer Programming.pptx
O2C Customer Invoices to Receipt V15A.pptx

How to scale with Terraform