SlideShare a Scribd company logo
1 of 20
How to write
cloud-agnostic
Terraform code
Giulio Vian
21/22 October 2020
Why this session?
Image by Sammy Williams
Assumption #1:
You know Terraform
Assumption #2:
Terraform ≥0.13
Code is provider specific: AWS
Code is provider specific: Azure
Abstraction
Cross-cutting services
Region
Cross-cutting services
Global
Networking
services
Networking
Networking
Computing &
Data
Blocks
Computing &
Data
Blocks
Abstract the architecture
Cross-cutting services
Region
Networking
Networking
Computing &
Data
Blocks
Computing &
Data
Blocks
Region
Computing Block Function as a
Service
Container as a
Service
Platform as a
Service
Inside a Component
Virtual
Machine
Instance
Stateless Firewall (IP/Port restriction)
Load Balancer
Subnet(s)
Enough slides
Enough slides
Goodies #1
count
module azure {
source = "../vm"
count = var.platform == "vm"
? 1 : 0
}
Goodies #2
variable location {
type = object({
cloud = string,
geography = string,
section = string
})
}
Goodies #4
variable platform {
type = string
validation {
condition = can(contains([
"vm", "k8s"], var.platform))
error_message = "Only "vm
" and "k8s" are supported."
}}
Goodies #3
region
provider "aws" {
region = local.primary
}
Goodies #5
data aws_subnet app_subnet {
filter {
name = "tag:Name"
values = [var.subnet_name]
}
}
Links
https://www.terraform.io/
Y.Brikman, Terraform - Up and Running, O′Reilly
(2019, 2nd ed.) https://www.amazon.co.uk/dp/1492046906
https://docs.microsoft.com/en-us/azure/architecture/aws-
professional/services
https://docs.microsoft.com/en-us/azure/architecture/gcp-
professional/services
https://github.com/giuliov/terraform-fun
https://www.slideshare.net/giuliov
Hardware spec:
1 KB RAM
(16KB after upgrade)
4 KB ROM
(8KB after upgrade)
First computer Past Companies Communities
Giulio Vian Senior DevOps Engineer
Address
giulio.dev@casavian.eu
@giulio_vian
https://www.slideshare.net/giuliov
http://blog.casavian.eu
https://medium.com/@giuliovdev
https://github.com/giuliov
End of trasmissions
21

More Related Content

Similar to How to write cloud-agnostic Terraform code - Incontro DevOps Italia 2020

(BAC404) Deploying High Availability and Disaster Recovery Architectures with...
(BAC404) Deploying High Availability and Disaster Recovery Architectures with...(BAC404) Deploying High Availability and Disaster Recovery Architectures with...
(BAC404) Deploying High Availability and Disaster Recovery Architectures with...Amazon Web Services
 
AWS re:Invent 2016: NEW LAUNCH! Introducing AWS Greengrass (IOT201)
AWS re:Invent 2016: NEW LAUNCH! Introducing AWS Greengrass (IOT201)AWS re:Invent 2016: NEW LAUNCH! Introducing AWS Greengrass (IOT201)
AWS re:Invent 2016: NEW LAUNCH! Introducing AWS Greengrass (IOT201)Amazon Web Services
 
Deploying Cloud Native Red Team Infrastructure with Kubernetes, Istio and Envoy
Deploying Cloud Native Red Team Infrastructure with Kubernetes, Istio and Envoy Deploying Cloud Native Red Team Infrastructure with Kubernetes, Istio and Envoy
Deploying Cloud Native Red Team Infrastructure with Kubernetes, Istio and Envoy Jeffrey Holden
 
Azure IoT & ML Recap - 20180503
Azure IoT & ML Recap - 20180503Azure IoT & ML Recap - 20180503
Azure IoT & ML Recap - 20180503Jamie (Taka) Wang
 
Architectural solutions for the cloud
Architectural solutions for the cloudArchitectural solutions for the cloud
Architectural solutions for the cloudthreesixty
 
AWS IoT & ML Recap - 20180423
AWS IoT & ML Recap - 20180423AWS IoT & ML Recap - 20180423
AWS IoT & ML Recap - 20180423Jamie (Taka) Wang
 
New Design Patterns in Microservice Solutions
New Design Patterns in Microservice SolutionsNew Design Patterns in Microservice Solutions
New Design Patterns in Microservice SolutionsMichel Burger
 
Deploying AWS IoT-managed devices in an industrial setting - SVC302 - Atlanta...
Deploying AWS IoT-managed devices in an industrial setting - SVC302 - Atlanta...Deploying AWS IoT-managed devices in an industrial setting - SVC302 - Atlanta...
Deploying AWS IoT-managed devices in an industrial setting - SVC302 - Atlanta...Amazon Web Services
 
Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?
Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?
Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?Julien Vermillard
 
Teridion Overview
Teridion OverviewTeridion Overview
Teridion OverviewBill Zajac
 
게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018Amazon Web Services Korea
 
Cld006 azure v_net___express_route_最新情報
Cld006 azure v_net___express_route_最新情報Cld006 azure v_net___express_route_最新情報
Cld006 azure v_net___express_route_最新情報Tech Summit 2016
 
Apollo Cloud Edge Solution - 20180518
Apollo Cloud Edge Solution - 20180518Apollo Cloud Edge Solution - 20180518
Apollo Cloud Edge Solution - 20180518Jamie (Taka) Wang
 
AWS BaseCamp: AWS Architecture Fundamentals
AWS BaseCamp: AWS  Architecture FundamentalsAWS BaseCamp: AWS  Architecture Fundamentals
AWS BaseCamp: AWS Architecture FundamentalsNicole Maus
 
AWS SSA Webinar 7 - Getting Started on AWS
AWS SSA Webinar 7 - Getting Started on AWSAWS SSA Webinar 7 - Getting Started on AWS
AWS SSA Webinar 7 - Getting Started on AWSCobus Bernard
 
Cld006 azure v_net___express_route_最新情報
Cld006 azure v_net___express_route_最新情報Cld006 azure v_net___express_route_最新情報
Cld006 azure v_net___express_route_最新情報Tech Summit 2016
 
Data Capture in IBM WebSphere Premises Server - Aldo Eisma, IBM
Data Capture in IBM WebSphere Premises Server - Aldo Eisma, IBMData Capture in IBM WebSphere Premises Server - Aldo Eisma, IBM
Data Capture in IBM WebSphere Premises Server - Aldo Eisma, IBMmfrancis
 

Similar to How to write cloud-agnostic Terraform code - Incontro DevOps Italia 2020 (20)

(BAC404) Deploying High Availability and Disaster Recovery Architectures with...
(BAC404) Deploying High Availability and Disaster Recovery Architectures with...(BAC404) Deploying High Availability and Disaster Recovery Architectures with...
(BAC404) Deploying High Availability and Disaster Recovery Architectures with...
 
AWS re:Invent 2016: NEW LAUNCH! Introducing AWS Greengrass (IOT201)
AWS re:Invent 2016: NEW LAUNCH! Introducing AWS Greengrass (IOT201)AWS re:Invent 2016: NEW LAUNCH! Introducing AWS Greengrass (IOT201)
AWS re:Invent 2016: NEW LAUNCH! Introducing AWS Greengrass (IOT201)
 
Deploying Cloud Native Red Team Infrastructure with Kubernetes, Istio and Envoy
Deploying Cloud Native Red Team Infrastructure with Kubernetes, Istio and Envoy Deploying Cloud Native Red Team Infrastructure with Kubernetes, Istio and Envoy
Deploying Cloud Native Red Team Infrastructure with Kubernetes, Istio and Envoy
 
Azure IoT & ML Recap - 20180503
Azure IoT & ML Recap - 20180503Azure IoT & ML Recap - 20180503
Azure IoT & ML Recap - 20180503
 
Architectural solutions for the cloud
Architectural solutions for the cloudArchitectural solutions for the cloud
Architectural solutions for the cloud
 
AWS IoT & ML Recap - 20180423
AWS IoT & ML Recap - 20180423AWS IoT & ML Recap - 20180423
AWS IoT & ML Recap - 20180423
 
Introduction To Cloud Computing
Introduction To Cloud ComputingIntroduction To Cloud Computing
Introduction To Cloud Computing
 
New Design Patterns in Microservice Solutions
New Design Patterns in Microservice SolutionsNew Design Patterns in Microservice Solutions
New Design Patterns in Microservice Solutions
 
Deploying AWS IoT-managed devices in an industrial setting - SVC302 - Atlanta...
Deploying AWS IoT-managed devices in an industrial setting - SVC302 - Atlanta...Deploying AWS IoT-managed devices in an industrial setting - SVC302 - Atlanta...
Deploying AWS IoT-managed devices in an industrial setting - SVC302 - Atlanta...
 
Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?
Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?
Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?
 
Azure webinar kolkata
Azure webinar kolkata Azure webinar kolkata
Azure webinar kolkata
 
Teridion Overview
Teridion OverviewTeridion Overview
Teridion Overview
 
게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
 
Cld006 azure v_net___express_route_最新情報
Cld006 azure v_net___express_route_最新情報Cld006 azure v_net___express_route_最新情報
Cld006 azure v_net___express_route_最新情報
 
Apollo Cloud Edge Solution - 20180518
Apollo Cloud Edge Solution - 20180518Apollo Cloud Edge Solution - 20180518
Apollo Cloud Edge Solution - 20180518
 
What Is Happening At The Edge
What Is Happening At The EdgeWhat Is Happening At The Edge
What Is Happening At The Edge
 
AWS BaseCamp: AWS Architecture Fundamentals
AWS BaseCamp: AWS  Architecture FundamentalsAWS BaseCamp: AWS  Architecture Fundamentals
AWS BaseCamp: AWS Architecture Fundamentals
 
AWS SSA Webinar 7 - Getting Started on AWS
AWS SSA Webinar 7 - Getting Started on AWSAWS SSA Webinar 7 - Getting Started on AWS
AWS SSA Webinar 7 - Getting Started on AWS
 
Cld006 azure v_net___express_route_最新情報
Cld006 azure v_net___express_route_最新情報Cld006 azure v_net___express_route_最新情報
Cld006 azure v_net___express_route_最新情報
 
Data Capture in IBM WebSphere Premises Server - Aldo Eisma, IBM
Data Capture in IBM WebSphere Premises Server - Aldo Eisma, IBMData Capture in IBM WebSphere Premises Server - Aldo Eisma, IBM
Data Capture in IBM WebSphere Premises Server - Aldo Eisma, IBM
 

More from Giulio Vian

Is Technical Debt the right metaphor for Continuous Update?
Is Technical Debt the right metaphor for Continuous Update?Is Technical Debt the right metaphor for Continuous Update?
Is Technical Debt the right metaphor for Continuous Update?Giulio Vian
 
Is Technical Debt the right metaphor for Continuous Update - AllDayDevOps 2022
Is Technical Debt the right metaphor for Continuous Update - AllDayDevOps 2022Is Technical Debt the right metaphor for Continuous Update - AllDayDevOps 2022
Is Technical Debt the right metaphor for Continuous Update - AllDayDevOps 2022Giulio Vian
 
Software rotting - DevOpsCon Berlin
Software rotting - DevOpsCon BerlinSoftware rotting - DevOpsCon Berlin
Software rotting - DevOpsCon BerlinGiulio Vian
 
Software rotting
Software rottingSoftware rotting
Software rottingGiulio Vian
 
Software rotting - 28 Apr - DeveloperWeek Europe 2022
Software rotting - 28 Apr - DeveloperWeek Europe 2022Software rotting - 28 Apr - DeveloperWeek Europe 2022
Software rotting - 28 Apr - DeveloperWeek Europe 2022Giulio Vian
 
L'impatto della sicurezza su DevOps
L'impatto della sicurezza su DevOpsL'impatto della sicurezza su DevOps
L'impatto della sicurezza su DevOpsGiulio Vian
 
L'impatto della sicurezza su DevOps
L'impatto della sicurezza su DevOpsL'impatto della sicurezza su DevOps
L'impatto della sicurezza su DevOpsGiulio Vian
 
A map for DevOps on Microsoft Stack - MS DevSummit
A map for DevOps on Microsoft Stack - MS DevSummitA map for DevOps on Microsoft Stack - MS DevSummit
A map for DevOps on Microsoft Stack - MS DevSummitGiulio Vian
 
Perché è così difficile il deploy dei database - DevCast DevOps Serie
Perché è così difficile il deploy dei database  - DevCast DevOps SeriePerché è così difficile il deploy dei database  - DevCast DevOps Serie
Perché è così difficile il deploy dei database - DevCast DevOps SerieGiulio Vian
 
Database deployments - dotnetsheff
Database deployments - dotnetsheffDatabase deployments - dotnetsheff
Database deployments - dotnetsheffGiulio Vian
 
Database deployment: still hard after all these years - Data Saturday #1
Database deployment: still hard after all these years - Data Saturday #1Database deployment: still hard after all these years - Data Saturday #1
Database deployment: still hard after all these years - Data Saturday #1Giulio Vian
 
Pipeline your Pipelines - 2020 All Day DevOps
Pipeline your Pipelines - 2020 All Day DevOpsPipeline your Pipelines - 2020 All Day DevOps
Pipeline your Pipelines - 2020 All Day DevOpsGiulio Vian
 
Top 10 pipeline mistakes - dotnetsheff
Top 10 pipeline mistakes - dotnetsheffTop 10 pipeline mistakes - dotnetsheff
Top 10 pipeline mistakes - dotnetsheffGiulio Vian
 
Introduction to Terraform with Azure flavor
Introduction to Terraform with Azure flavorIntroduction to Terraform with Azure flavor
Introduction to Terraform with Azure flavorGiulio Vian
 
How collaboration works between Dev and Ops - DevOps Agile Testing and Test S...
How collaboration works between Dev and Ops - DevOps Agile Testing and Test S...How collaboration works between Dev and Ops - DevOps Agile Testing and Test S...
How collaboration works between Dev and Ops - DevOps Agile Testing and Test S...Giulio Vian
 
Usare SQL Server for Linux e Docker per semplificare i processi di testing - ...
Usare SQL Server for Linux e Docker per semplificare i processi di testing - ...Usare SQL Server for Linux e Docker per semplificare i processi di testing - ...
Usare SQL Server for Linux e Docker per semplificare i processi di testing - ...Giulio Vian
 
Pipeline your pipelines!
Pipeline your pipelines!Pipeline your pipelines!
Pipeline your pipelines!Giulio Vian
 
Why is DevOps vital for my company’s business
Why is DevOps vital for my company’s businessWhy is DevOps vital for my company’s business
Why is DevOps vital for my company’s businessGiulio Vian
 
Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)Giulio Vian
 
Terraform for Azure Quickstart
Terraform for Azure QuickstartTerraform for Azure Quickstart
Terraform for Azure QuickstartGiulio Vian
 

More from Giulio Vian (20)

Is Technical Debt the right metaphor for Continuous Update?
Is Technical Debt the right metaphor for Continuous Update?Is Technical Debt the right metaphor for Continuous Update?
Is Technical Debt the right metaphor for Continuous Update?
 
Is Technical Debt the right metaphor for Continuous Update - AllDayDevOps 2022
Is Technical Debt the right metaphor for Continuous Update - AllDayDevOps 2022Is Technical Debt the right metaphor for Continuous Update - AllDayDevOps 2022
Is Technical Debt the right metaphor for Continuous Update - AllDayDevOps 2022
 
Software rotting - DevOpsCon Berlin
Software rotting - DevOpsCon BerlinSoftware rotting - DevOpsCon Berlin
Software rotting - DevOpsCon Berlin
 
Software rotting
Software rottingSoftware rotting
Software rotting
 
Software rotting - 28 Apr - DeveloperWeek Europe 2022
Software rotting - 28 Apr - DeveloperWeek Europe 2022Software rotting - 28 Apr - DeveloperWeek Europe 2022
Software rotting - 28 Apr - DeveloperWeek Europe 2022
 
L'impatto della sicurezza su DevOps
L'impatto della sicurezza su DevOpsL'impatto della sicurezza su DevOps
L'impatto della sicurezza su DevOps
 
L'impatto della sicurezza su DevOps
L'impatto della sicurezza su DevOpsL'impatto della sicurezza su DevOps
L'impatto della sicurezza su DevOps
 
A map for DevOps on Microsoft Stack - MS DevSummit
A map for DevOps on Microsoft Stack - MS DevSummitA map for DevOps on Microsoft Stack - MS DevSummit
A map for DevOps on Microsoft Stack - MS DevSummit
 
Perché è così difficile il deploy dei database - DevCast DevOps Serie
Perché è così difficile il deploy dei database  - DevCast DevOps SeriePerché è così difficile il deploy dei database  - DevCast DevOps Serie
Perché è così difficile il deploy dei database - DevCast DevOps Serie
 
Database deployments - dotnetsheff
Database deployments - dotnetsheffDatabase deployments - dotnetsheff
Database deployments - dotnetsheff
 
Database deployment: still hard after all these years - Data Saturday #1
Database deployment: still hard after all these years - Data Saturday #1Database deployment: still hard after all these years - Data Saturday #1
Database deployment: still hard after all these years - Data Saturday #1
 
Pipeline your Pipelines - 2020 All Day DevOps
Pipeline your Pipelines - 2020 All Day DevOpsPipeline your Pipelines - 2020 All Day DevOps
Pipeline your Pipelines - 2020 All Day DevOps
 
Top 10 pipeline mistakes - dotnetsheff
Top 10 pipeline mistakes - dotnetsheffTop 10 pipeline mistakes - dotnetsheff
Top 10 pipeline mistakes - dotnetsheff
 
Introduction to Terraform with Azure flavor
Introduction to Terraform with Azure flavorIntroduction to Terraform with Azure flavor
Introduction to Terraform with Azure flavor
 
How collaboration works between Dev and Ops - DevOps Agile Testing and Test S...
How collaboration works between Dev and Ops - DevOps Agile Testing and Test S...How collaboration works between Dev and Ops - DevOps Agile Testing and Test S...
How collaboration works between Dev and Ops - DevOps Agile Testing and Test S...
 
Usare SQL Server for Linux e Docker per semplificare i processi di testing - ...
Usare SQL Server for Linux e Docker per semplificare i processi di testing - ...Usare SQL Server for Linux e Docker per semplificare i processi di testing - ...
Usare SQL Server for Linux e Docker per semplificare i processi di testing - ...
 
Pipeline your pipelines!
Pipeline your pipelines!Pipeline your pipelines!
Pipeline your pipelines!
 
Why is DevOps vital for my company’s business
Why is DevOps vital for my company’s businessWhy is DevOps vital for my company’s business
Why is DevOps vital for my company’s business
 
Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)
 
Terraform for Azure Quickstart
Terraform for Azure QuickstartTerraform for Azure Quickstart
Terraform for Azure Quickstart
 

Recently uploaded

Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 

Recently uploaded (20)

Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 

How to write cloud-agnostic Terraform code - Incontro DevOps Italia 2020

Editor's Notes

  1. Good afternoon everyone, thanks for your time to attend this session We will explore how to abstract our Terraform code from being provider specific and how to leverage a few cool features of Terraform 0.12 and 0.13. So, even if you are not interested in technological agnosticism, you might enjoy a practical example of latest Terraform abilities. All the code is publicly available in GitHub.
  2. I was involved in a customer project and the customer insisted on using two major cloud vendors. This is a common request from big customers: they do not want to put all their eggs in the same basket. Studying the two vendors documentation and knowing Terraform well, I demonstrated the ability to build the same infrastructure on either platforms. How it worked out in the end? that, like most customers, the management is uncomfortable with the multi-cloud concept and opts for a multi-vendor strategy. Different workloads land on different cloud providers. I think that consulting businesses can and should go multi-cloud. In preparing this session, I choose to focus on the most known and used cloud platforms: Amazon AWS and Microsoft Azure. My customer made a different choice then.
  3. Before we move on, there is an important announce. I will not explain the basics of Terraform, because I assume that you know them, at least enough to understand the samples. I hope you discover with me that cloud are more similar than different. But there is more.
  4. The sample code use Terraform 0.13 and will not work with earlier version.
  5. To allocate a Virtual Machine in AWS through Terraform, you write code that is specific for the AWS Provider. In this basic example you ask Terraform to configure an "aws_instance" resource. The fundamental properties to setup a VM are: - the operating system image, it can be a barebone Linux or a full-fledged Oracle instance or a custom configuration you setup yourself; - the computing resources to use, mainly CPU and RAM, but may include GPUs, special networking, special hardware; - how the VM is connected to the network; - and the machine identifier, which in AWS is a special tag. Now, let’s take a look at the equivalent code for Azure.
  6. This is the code to allocate a Ubuntu virtual machine in Azure. You can notice some important differences that we have to smooth out to make our code agnostic. The Region (location) is an explicit parameter, while for AWS it is tied to the provider configuration. The OS image is identified using four keys instead of a single identifier. The networking is quite different as Azure has a separate resource, while AWS is just a property of the instance. The Azure provider requires to specify some settings which have a default value in AWS. Now, given the similarities how do we generalise the code?
  7. "We can solve any problem by introducing an extra level of indirection." I bet this isn’t a real surprise for you, right? In practice, we must abstract the differences between providers through Terraform modules. The module parameters must be provider-neutral and translated to provider-specific values and formats. It is important to pick the right abstractions so that we end up with a rich model where we can define a great deal of details and can combine simple components in a complex ways. My recommendation is a top-down approach.
  8. A top-down approach starts by looking at the overall architecture of our systems and moves down to finer graded components. The diagram illustrates my personal choice for decomposing a system. The Global block contains cross-cutting services like IAM / AAD, that is, users, groups and permissions and networking that connects resources across regions (mostly for a disaster recovery implementation). Within a region, you have a segment which represents an application, living in a distinct part of the network. A segment may represent availability zones too. A Data block can be an S3 bucket / Azure Storage or an RDS / Azure Database instance. Microsoft even has a couple of pages mapping AWS and GCP services to the Azure equivalent. Note that you do not need to abstract every possible component. For examples, networking infrastructure like Express Route (Az) / Direct Connect (AWS) can be setup once and plugged into the abstract modules. Also Terraform data sources are a great help in decoupling modules and abstracting resources. The goal is to minimise the migration effort. Let’s see a bit more details before delving into code.
  9. This is just a decomposition example. A computing block abstracts network and computing resources with tight bounds. For example, an auto-scaling / VM scales set group needs a load balancer; ports must be open for traffic to flow in and out. This abstract block can be further specified to be a serverless (Function/Lambda) resource, or a container (ACI/ECS/Fargate) or a VM. I think this is enough abstract talk, let’s see some concrete example.
  10. The demo code is not a full-blown decomposition. It demonstrates the allocation of a Virtual Machine in either AWS or Azure. (switch to demo)
  11. And this wraps up the demo.
  12. We learned a few things about Terraform 0.13 The count pseudo-argument can be used with modules and this is the best new feature in my opinion.
  13. You can use objects to simplify and reduce the number of module parameters.
  14. Variables can be checked before use and get a meaningful error message when required.
  15. The region of AWS provider can be an expression, dynamically calculated, and you can pass this provider configuration to submodules.
  16. Terraform Data sources are a great way to simplify your modules, reducing coupling and the number of input / output parameters.
  17. This is a bunch of, hopefully, useful links. Terraform documentation. The best known book to learn Terraform. In case you bought the first edition like me, the second edition is finally out. A couple of Microsoft documentation pages listing side by side the equivalent AWS or GCP service. The link of the GitHub repository with the complete source code and the link to this presentation’s slides.
  18. Some information on yours truly. I started with poor hardware when writing assembly code was not exceptional. I worked for some companies over the years in quite a few different roles, now I work for Unum, a Fortune 500 insurance company. Recognised by Microsoft with the Most Valuable Professional award in the last 5 years, I like to help communities throughout Europe.
  19. Some information on yours truly. I started with poor hardware when writing assembly code was not exceptional. I worked for some companies over the years in quite a few different roles, now I work for Unum, a Fortune 500 insurance company. Recognised by Microsoft with the Most Valuable Professional award in the last 5 years, I like to help communities throughout Europe.
  20. And here are some references if you want to get in touch with me.