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

PDF
Terraform 101
PPTX
Talk be secret like a ninja with Vault
PDF
Jaringan, Linux, Docker
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
Terraform 101
Talk be secret like a ninja with Vault
Jaringan, Linux, Docker
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
Terraforming your Infrastructure on GCP
PDF
DevOps Braga #9: Introdução ao Terraform
PDF
AWS DevOps - Terraform, Docker, HashiCorp Vault
PDF
Commodified IaC using Terraform Cloud
PDF
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
PDF
Terraform-2.pdf
PDF
Self-service PR-based Terraform
PDF
Git ops & Continuous Infrastructure with terra*
PDF
Workshop Infrastructure as Code - Suestra
PDF
20170831 - Greg Palmier: Terraform & AWS at Tempus
PPTX
Infrastructure-as-Code (IaC) Using Terraform (Advanced Edition)
PDF
Terraform – Infrastructure as Code (Kielux'18)
PDF
Terraform introduction
PDF
Terraform GitOps on Codefresh
PPTX
Terraform Abstractions for Safety and Power
PPTX
Scaling with Automation
PDF
The hitchhiker's guide to terraform your infrastructure (hashiconf)
PPTX
"Continuously delivering infrastructure using Terraform and Packer" training ...
PDF
Introduce to Terraform
PDF
Terraform - Taming Modern Clouds
Terraforming your Infrastructure on GCP
DevOps Braga #9: Introdução ao Terraform
AWS DevOps - Terraform, Docker, HashiCorp Vault
Commodified IaC using Terraform Cloud
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Terraform-2.pdf
Self-service PR-based Terraform
Git ops & Continuous Infrastructure with terra*
Workshop Infrastructure as Code - Suestra
20170831 - Greg Palmier: Terraform & AWS at Tempus
Infrastructure-as-Code (IaC) Using Terraform (Advanced Edition)
Terraform – Infrastructure as Code (Kielux'18)
Terraform introduction
Terraform GitOps on Codefresh
Terraform Abstractions for Safety and Power
Scaling with Automation
The hitchhiker's guide to terraform your infrastructure (hashiconf)
"Continuously delivering infrastructure using Terraform and Packer" training ...
Introduce to Terraform
Terraform - Taming Modern Clouds
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
EGCB_Solar_Project_Presentation_and Finalcial Analysis.pdf
PDF
Addressing the challenges of harmonizing law and artificial intelligence tech...
PPT
Overviiew on Intellectual property right
PDF
Peak of Data & AI Encore: Scalable Design & Infrastructure
PDF
Domain-specific knowledge and context in large language models: challenges, c...
PDF
Child-friendly e-learning for artificial intelligence education in Indonesia:...
PDF
TicketRoot: Event Tech Solutions Deck 2025
PDF
【AI論文解説】高速・高品質な生成を実現するFlow Map Models(Part 1~3)
PDF
Rooftops detection with YOLOv8 from aerial imagery and a brief review on roof...
PDF
State of AI in Business 2025 - MIT NANDA
PDF
Applying Agentic AI in Enterprise Automation
PPTX
Introduction-to-Artificial-Intelligence (1).pptx
PDF
Ebook - The Future of AI A Comprehensive Guide.pdf
PDF
Revolutionizing recommendations a survey: a comprehensive exploration of mode...
PDF
CCUS-as-the-Missing-Link-to-Net-Zero_AksCurious.pdf
PDF
Examining Bias in AI Generated News Content.pdf
PPTX
From Curiosity to ROI — Cost-Benefit Analysis of Agentic Automation [3/6]
PDF
Intravenous drug administration application for pediatric patients via augmen...
PPTX
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com
PDF
Introduction to c language from lecture slides
EGCB_Solar_Project_Presentation_and Finalcial Analysis.pdf
Addressing the challenges of harmonizing law and artificial intelligence tech...
Overviiew on Intellectual property right
Peak of Data & AI Encore: Scalable Design & Infrastructure
Domain-specific knowledge and context in large language models: challenges, c...
Child-friendly e-learning for artificial intelligence education in Indonesia:...
TicketRoot: Event Tech Solutions Deck 2025
【AI論文解説】高速・高品質な生成を実現するFlow Map Models(Part 1~3)
Rooftops detection with YOLOv8 from aerial imagery and a brief review on roof...
State of AI in Business 2025 - MIT NANDA
Applying Agentic AI in Enterprise Automation
Introduction-to-Artificial-Intelligence (1).pptx
Ebook - The Future of AI A Comprehensive Guide.pdf
Revolutionizing recommendations a survey: a comprehensive exploration of mode...
CCUS-as-the-Missing-Link-to-Net-Zero_AksCurious.pdf
Examining Bias in AI Generated News Content.pdf
From Curiosity to ROI — Cost-Benefit Analysis of Agentic Automation [3/6]
Intravenous drug administration application for pediatric patients via augmen...
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com
Introduction to c language from lecture slides

How to scale with Terraform