SlideShare a Scribd company logo
Three Problems of Terraform
—
Why People Keep Writing Terraform Wrappers
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
https://www.grc.com/sn/sn-923-notes.pdf
www.fivexl.io | hello@fivexl.io
Do it.
Do it better.
Do it right.
Alex Lindsay
www.fivexl.io | hello@fivexl.io
https://www.amazon.es/durstige-Tuborg-Bier-Henningsen-Dinamarca-Plakate/dp/B088HJJD23
www.fivexl.io | hello@fivexl.io
Andrey Devyatkin
Co-Host at DevSecOps
Talks podcast
Principal Cloud
Engineering Specialist
AWS Community
Builder
Co-Founder at FivexL
Public speaker
www.fivexl.io | hello@fivexl.io
https://www.istockphoto.com/es/foto/mano-de-gato-levantada-gm914509428-251700990
2023-05-24 - Three problems of Terraform DevOps Pro EU.pdf
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
three
conceptual
problems
Dynamic state location
Deploying the same configuration to multiple
environments
Environment specific parameters
A way to address differences between environments
Cross-state resources lookup
A need to reference resources from different states
www.fivexl.io | hello@fivexl.io
Assumptions
AWS
www.fivexl.io | hello@fivexl.io
https://www.primevideo.com/detail/Silicon-Valley/0PHZ6LOP10TB423SCOM0BMCFMM
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
$ ls
README.md
.terraform
main.tf
terraform.tfstate
www.fivexl.io | hello@fivexl.io
terraform {
backend "s3" {
bucket = "my-cool-startup-infra-state"
key = "terraform/main.tfstate"
region = "us-east-1"
}
}
www.fivexl.io | hello@fivexl.io
Assumptions
AWS
S3 backend
www.fivexl.io | hello@fivexl.io
So far so good
No need for the wrapper
www.fivexl.io | hello@fivexl.io
https://www.amazon.co.uk/Silicon-Valley-Season-2-DVD/dp/B018I8RFZS
www.fivexl.io | hello@fivexl.io
We need to deploy the app to
the second environment
www.fivexl.io | hello@fivexl.io
Assumptions
AWS
dev/production
S3 backend
www.fivexl.io | hello@fivexl.io
We need to change
backend configuration
depending on env
www.fivexl.io | hello@fivexl.io
terraform {
backend "s3" {
bucket = "my-cool-startup-infra-state"
key = "terraform/main.tfstate"
region = "us-east-1"
}
}
www.fivexl.io | hello@fivexl.io
https://github.com/hashicorp/terraform/issues/17288
www.fivexl.io | hello@fivexl.io
Can we use Terraform
workspaces?
www.fivexl.io | hello@fivexl.io
https://developer.hashicorp.com/terraform/cli/workspaces
As of 2023-05-18
www.fivexl.io | hello@fivexl.io
https://developer.hashicorp.com/terraform/cli/workspaces#when-not-to-use-multiple-workspaces
As of 2023-05-18
Okay, what is the real life use case then?
🤔
www.fivexl.io | hello@fivexl.io
https://developer.hashicorp.com/terraform/cli/workspaces#alternatives-to-workspaces
As of 2023-05-18
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
https://terragrunt.gruntwork.io/docs/features/keep-your-terragrunt-architecture-dry/
www.fivexl.io | hello@fivexl.io
But why so many
directories? Can’t we just
use the same directory
somehow? 🤔
www.fivexl.io | hello@fivexl.io
https://developer.hashicorp.com/terraform/language/settings/backends/configuration#partial-configuration
As of 2023-05-18
www.fivexl.io | hello@fivexl.io
terraform {
backend "s3" {
bucket = "my-cool-startup-infra-state"
key = "terraform/main.tfstate"
region = "us-east-1"
}
}
www.fivexl.io | hello@fivexl.io
terraform {
backend "s3" {}
}
terraform init 
-backend-config "bucket=my-cool-startup-infra-state" 
-backend-config "key=terraform/main.tfstate" 
-backend-config "region=us-east-1"
www.fivexl.io | hello@fivexl.io
Do we share S3 bucket
between environments?
www.fivexl.io | hello@fivexl.io
Assumptions
AWS
dev/production
S3 backend
bucket/state per env with
predefined name
www.fivexl.io | hello@fivexl.io
terraform {
backend "s3" {}
}
terraform init 
-backend-config "infra-state-798424800762" 
-backend-config "key=terraform/main.tfstate" 
-backend-config "region=us-east-1"
www.fivexl.io | hello@fivexl.io
Why did we name s3
bucket this way? 🤔
www.fivexl.io | hello@fivexl.io
format("infra-state-%s",
data.aws_caller_identity.current.account_id)
www.fivexl.io | hello@fivexl.io
Would exposing the account
id get us into trouble? 🤔
www.fivexl.io | hello@fivexl.io
https://www.lastweekinaws.com/blog/are-aws-account-ids-sensitive-information/
www.fivexl.io | hello@fivexl.io
# debatable
format("infra-state-%s",
data.aws_caller_identity.current.account_id)
# paranoid edition
format("infra-state-%s",
sha1(data.aws_caller_identity.current.account_id))
www.fivexl.io | hello@fivexl.io
Why not just use env
suffix like -prod or -dev?
🤔
www.fivexl.io | hello@fivexl.io
If we are using the same dir
then how to be with .terraform?
🤔
www.fivexl.io | hello@fivexl.io
https://developer.hashicorp.com/terraform/cli/config/environment-variables#tf_data_dir
As of 2023-05-18
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
AWS_DEFAULT_REGION
env variable?
Use aws-vault for env setup
www.fivexl.io | hello@fivexl.io
$ ls
README.md
.terraform.798424800762
.terraform.813771662528
main.tf
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
How do we specify different
parameters for different
environments?
www.fivexl.io | hello@fivexl.io
https://developer.hashicorp.com/terraform/language/values/variables#assigning-values-to-root-module-variables
As of 2023-05-18
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
$ ls
README.md
798424800762.tfvars
813771662528.tfvars
.terraform.798424800762
.terraform.813771662528
main.tf
$ cat 798424800762.tfvars
# dev
instance_type = "t4g.micro"
$ cat 813771662528.tfvars
# prod
instance_type = "t4g.large"
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
Do we really need a
wrapper for this?
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
What if we add more
applications?
www.fivexl.io | hello@fivexl.io
https://infrastructure-as-code.com/book/2018/03/28/defining-stacks.html
www.fivexl.io | hello@fivexl.io
https://www.youtube.com/watch?v=wgzgVm7Sqlk
www.fivexl.io | hello@fivexl.io
How do I get VPC id from network
stack to my application stack?
www.fivexl.io | hello@fivexl.io
https://developer.hashicorp.com/terraform/language/state/remote-state-data
www.fivexl.io | hello@fivexl.io
Terragrunt remote state resoltion
www.fivexl.io | hello@fivexl.io
AWS SSM
Parameters
AWS S3
Self-containing
modules
Are the other ways?
Tooling
www.fivexl.io | hello@fivexl.io
Self-contained
modules? 🤔
Create resources
Look up resources
Provide policies
…
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
Conclusion and
recap
www.fivexl.io | hello@fivexl.io
three
conceptual
problems
Dynamic state location
Deploying the same configuration to multiple
environments
Environment specific parameters
A way to address differences between environments
Cross-state resources lookup
A need to reference resources from different states
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
conventions vs wrappers
www.fivexl.io | hello@fivexl.io
You can remove bash (if Terraform
problems get solved one day),
much harder to remove more complex
solutions like Terragrunt
Thank you
https://github.com/Andrey9kin/3-terraform-problems
https://twitter.com/andrey9kin
https://www.linkedin.com/in/andreydevyatkin/
andrey.devyatkin@fivexl.io

More Related Content

PDF
AWS Community Day CPH 2024 - Three problems of Terraform
PDF
Managing AWS Using Terraform AWS Atlanta 2018-07-18
PDF
Managing AWS Using Terraform AWS Chicago-Suburbs 2018-01-18
PDF
Getting Started with AWS - Enterprise Landing Zone for Terraform Learning & D...
PDF
Building infrastructure as code using Terraform - DevOps Krakow
PPTX
Terraform - The Road to Self-Service
PDF
Terraform Q&A - HashiCorp User Group Oslo
PDF
Terraform introduction
AWS Community Day CPH 2024 - Three problems of Terraform
Managing AWS Using Terraform AWS Atlanta 2018-07-18
Managing AWS Using Terraform AWS Chicago-Suburbs 2018-01-18
Getting Started with AWS - Enterprise Landing Zone for Terraform Learning & D...
Building infrastructure as code using Terraform - DevOps Krakow
Terraform - The Road to Self-Service
Terraform Q&A - HashiCorp User Group Oslo
Terraform introduction

Similar to 2023-05-24 - Three problems of Terraform DevOps Pro EU.pdf (20)

PPTX
Hashicorp-Certified-Terraform-Associate-v3-edited.pptx
PDF
Terraform at Scale - All Day DevOps 2017
PPTX
Terraform Abstractions for Safety and Power
PDF
Terraform -- Infrastructure as Code
PPTX
Terraform in production - experiences, best practices and deep dive- Piotr Ki...
PPTX
terraform cours intéressant et super fort
PPTX
AWS Security best practices Terraform AWS security
PDF
Terraform modules and best-practices - September 2018
PDF
Terraform tfstate
PPTX
"Continuously delivering infrastructure using Terraform and Packer" training ...
PPTX
Terraform
PDF
Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...
PDF
Infrastructure as Code with Terraform
PDF
Terraform 0.9 + good practices
PDF
OSDC 2018 | Lifecycle of a resource. Codifying infrastructure with Terraform ...
PDF
Terraform AWS modules and some best-practices - May 2019
PDF
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
PDF
Terraform-2.pdf
PPTX
DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...
PDF
Devops Columbia October 2020 - Gabriel Alix: A Discussion on Terraform
Hashicorp-Certified-Terraform-Associate-v3-edited.pptx
Terraform at Scale - All Day DevOps 2017
Terraform Abstractions for Safety and Power
Terraform -- Infrastructure as Code
Terraform in production - experiences, best practices and deep dive- Piotr Ki...
terraform cours intéressant et super fort
AWS Security best practices Terraform AWS security
Terraform modules and best-practices - September 2018
Terraform tfstate
"Continuously delivering infrastructure using Terraform and Packer" training ...
Terraform
Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...
Infrastructure as Code with Terraform
Terraform 0.9 + good practices
OSDC 2018 | Lifecycle of a resource. Codifying infrastructure with Terraform ...
Terraform AWS modules and some best-practices - May 2019
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Terraform-2.pdf
DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...
Devops Columbia October 2020 - Gabriel Alix: A Discussion on Terraform
Ad

More from Andrey Devyatkin (16)

PDF
AWS Summit AMS 2025 - Beyond 3: Scaling to 50 AWS Accounts Without Losing Con...
PDF
AWS Summit AMS 2024 - From Complexity to Clarity
PDF
2023-11-23-AWS-UG-Las-Palmas-Increase-your-security-posture-with-temporary-el...
PDF
2023-09-28-AWS Las Palmas UG - Dynamic Anti-Frigile Systems.pdf
PDF
HashiConf Digital 2020: HashiCorp Vault configuration as code via HashiCorp T...
PDF
2020-02-20 - HashiCorpUserGroup Madring - Integrating HashiCorp Vault and Kub...
PDF
2020-02-20 - HashiTalks 2020 - HashiCorp Vault configuration as code via Hash...
PDF
HashiCorp Vault configuration as code via HashiCorp Terraform- stories from t...
PDF
2019 03-21 - cloud native computing las palmas meetup #1
PDF
Cloud Native Computing Las Palmas. Meetup #0
PDF
The state of Jenkins pipelines or do I still need freestyle jobs
PDF
Running jenkins in a public cloud - common issues and some solutions
PDF
Stockholm JAM September 2018
PDF
Getting Git Right @ Git Merge 2018
PDF
Stockholm Jenkins Area Meetup, March 2017
PDF
Synchronizing parallel delivery flows in jenkins using groovy, build flow and...
AWS Summit AMS 2025 - Beyond 3: Scaling to 50 AWS Accounts Without Losing Con...
AWS Summit AMS 2024 - From Complexity to Clarity
2023-11-23-AWS-UG-Las-Palmas-Increase-your-security-posture-with-temporary-el...
2023-09-28-AWS Las Palmas UG - Dynamic Anti-Frigile Systems.pdf
HashiConf Digital 2020: HashiCorp Vault configuration as code via HashiCorp T...
2020-02-20 - HashiCorpUserGroup Madring - Integrating HashiCorp Vault and Kub...
2020-02-20 - HashiTalks 2020 - HashiCorp Vault configuration as code via Hash...
HashiCorp Vault configuration as code via HashiCorp Terraform- stories from t...
2019 03-21 - cloud native computing las palmas meetup #1
Cloud Native Computing Las Palmas. Meetup #0
The state of Jenkins pipelines or do I still need freestyle jobs
Running jenkins in a public cloud - common issues and some solutions
Stockholm JAM September 2018
Getting Git Right @ Git Merge 2018
Stockholm Jenkins Area Meetup, March 2017
Synchronizing parallel delivery flows in jenkins using groovy, build flow and...
Ad

Recently uploaded (20)

PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
top salesforce developer skills in 2025.pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Essential Infomation Tech presentation.pptx
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Introduction to Artificial Intelligence
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
medical staffing services at VALiNTRY
PPTX
history of c programming in notes for students .pptx
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
top salesforce developer skills in 2025.pdf
Reimagine Home Health with the Power of Agentic AI​
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
How to Choose the Right IT Partner for Your Business in Malaysia
Essential Infomation Tech presentation.pptx
CHAPTER 2 - PM Management and IT Context
Odoo Companies in India – Driving Business Transformation.pdf
Introduction to Artificial Intelligence
PTS Company Brochure 2025 (1).pdf.......
medical staffing services at VALiNTRY
history of c programming in notes for students .pptx
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Operating system designcfffgfgggggggvggggggggg
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Odoo POS Development Services by CandidRoot Solutions
How Creative Agencies Leverage Project Management Software.pdf
Upgrade and Innovation Strategies for SAP ERP Customers
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...

2023-05-24 - Three problems of Terraform DevOps Pro EU.pdf