SlideShare a Scribd company logo
Production-Ready Terraform Deployments on Azure
Azure Meetup Hamburg, July 2021
Nico Meisenzahl
• Senior Cloud & DevOps Consultant at white duck
• Microsoft MVP, Docker Community Leader &
GitLab Hero
• Container, Kubernetes, Cloud-Native & DevOps
© white duck GmbH 2021
Phone: +49 8031 230159 0
Email: nico.meisenzahl@whiteduck.de
Twitter: @nmeisenzahl
LinkedIn: https://www.linkedin.com/in/nicomeisenzahl
Blog: https://meisenzahl.org
Agenda
• What is Infrastructure as Code and why do we need it?
• Get started with Terraform
• Demo: Terraform on Azure
© white duck GmbH 2021
What is Infrastructure as Code?
Infrastructure as Code (IaC) is the management and
provisioning of infrastructure through code rather
than manual processes.
© white duck GmbH 2021
Infrastructure as Code is…
• version controlled through Git
• automated through CI/CD
• reusable
• self-documented
• declarative
© white duck GmbH 2021
Declarative vs imperative
© white duck GmbH 2021
Why do we need IaC?
• to prevent configuration drift
• to recover quickly (rollback, restore)
• to reproduce errors & test our infrastructure
• to reduce costs & time-to-market
© white duck GmbH 2021
Infrastructure vs. configuration
• infrastructure orchestration is used to provision & manage
immutable infrastructure like Cloud resources
• e.g. provisioning of a Resource Group containing a Function App
• with Terraform, ARM Templates, Pulumi, AWS CloudFormation, …
• configuration management can be used to configure/maintain
mutable resources
• e.g. installing or configuring something within a Virtual Machine
• With Ansible, Chef, Puppet, Saltstack, …
© white duck GmbH 2021
What is Terraform?
Terraform is an Infrastructure as Code tool that
provides a consistent CLI workflow to manage
hundreds of cloud services.
Terraform codifies cloud APIs into declarative
configuration files.
© white duck GmbH 2021
What is Terraform?
• contains of
• a CLI
• a domain specific language (DSL)
• supports hundreds of cloud services
• extendable and therefore flexible
• is not a configuration tool
• introduced and open-sourced by Hashicorp
• is defacto the tool of choice
© white duck GmbH 2021
Terraform Providers
• Terraform relies on plugins called "providers" to interact
with Cloud resources
• Resource types are implemented by a provider
• Terraform itself cannot manage any resources
• are provided by
• Hashicorp (official flag)
• Cloud Providers and Third-Party (verified flag)
• open-source community (community flag)
• yourself J
© white duck GmbH 2021
Terraform Modules
• are “containers” for multiple resources that are used
together
• are the main way to package and reuse resource
configurations
• are stored locally (subfolder) or can be shared/published
© white duck GmbH 2021
Terraform Registry
© white duck GmbH 2021
Hashicorp Configuration Language - HCL
• a DSL (domain specific language) used to describe
resources
• there is also the Cloud Development Kit (CDK)
• supports TypeScript, Python, Java, C#, Golang
• early-stage project
• https://github.com/hashicorp/terraform-cdk
© white duck GmbH 2021
HCL sample
© white duck GmbH 2021
Terraform workflow
© white duck GmbH 2021
Terraform State
• is used to map “real world” resources to your configuration
• code à state ß real world
• stores Terraform-managed resources
• contains all infrastructure and metadata
• incl. secrets!
• local by default but should be stored remote backend
• Terraform Cloud
• Azure Storage Account
• AWS, GCP, GitLab, …
• …
© white duck GmbH 2021
Terraform CLI
© white duck GmbH 2021
Terraform workflow
© white duck GmbH 2021
Production-ready workflow (PR)
© white duck GmbH 2021
Terraform sample project structure
© white duck GmbH 2021
Generic Providers
• Template Provider
• allows injecting variables into config files
• https://registry.terraform.io/providers/hashicorp/template/latest
• Random Provider
• generates random strings, id, integer, passwords
• https://registry.terraform.io/providers/hashicorp/random/latest
• TLS Provider
• used to generate keys and certificates
• https://registry.terraform.io/providers/hashicorp/tls/latest
• Null Provider
• advanced - helps orchestrate tricky behavior or work arounds
• https://registry.terraform.io/providers/hashicorp/null/latest
© white duck GmbH 2021
Terraform providers for Azure
• Azure RM provider
• https://registry.terraform.io/providers/hashicorp/azurerm/latest
• Azure AAD provider
• https://registry.terraform.io/providers/hashicorp/azuread/latest
• Azure Stack provider
• https://registry.terraform.io/providers/hashicorp/azurestack/latest
• Azure DevOps provider
• https://registry.terraform.io/providers/microsoft/azuredevops/latest
• GitHub provider
• https://registry.terraform.io/providers/integrations/github/latest
© white duck GmbH 2021
Generic resources
• Data resource
• used to retrieve meta data from unmanaged resources
• Remote state resource
• used to retrieve meta data from “other” projects
• https://registry.terraform.io/providers/hashicorp/terraform/latest/
docs/data-sources/remote_state
© white duck GmbH 2021
Variables
• input variables
• serves as parameters for a module or project
• output variables
• child module can use outputs to expose resource attributes
• print certain values in the CLI for further usage
• local variables
• are a convenience feature for assigning a short name to any
expression
© white duck GmbH 2021
Meta arguments & functions
• Terraform supports meta arguments like
• count, for_each
• depends_on, lifecycle
• and a variety of functions like
• numeric, string, encoding, hash, crypto, …
• https://www.terraform.io/docs/language/functions/index.html
© white duck GmbH 2021
Provisioners
• should only be used as a last option
• are not declarative!
• Terraform supports
• file
• local_exec
• remote_exec
• https://www.terraform.io/docs/language/resources/provisioners/i
ndex.html
© white duck GmbH 2021
Environment stages in Terraform
• build one project for all stages (DEV, QS/QA, PROD, …)
• build it customizable via variables
• repositories vs branches
• state management via
• Terraform “Workspaces”
• uses one backend with multiple states
• not supported by all backends
• customizable backends
• different Backend configurations
• inject backend details via CLI/Shell
© white duck GmbH 2021
Terraform vs ARM Templates
• Terraform
• extendable and therefore flexible
• multi-cloud
• requires some work to run it production-ready (CI/CD, state)
• also supports ARM templates for advanced use-cases
• ARM Templates
• first-class support on Azure (but also limited to Azure)
• “only” Azure resources, no Azure AAD, etc.
• easy start with Bicep (https://github.com/Azure/bicep)
© white duck GmbH 2021
Demo: Terraform on Azure
• scaffold a first Terraform project
• provision some Azure resources
© white duck GmbH 2021
Authentication with Azure RM / Azure AD
• local Azure CLI
• Service Principal with a Client Certificate
• Service Principal with a Client Secret
• Managed Identity
© white duck GmbH 2021
Terraform scaffold for Azure
• provisions
• a service principal used to run Terraform on behalf
• a Storage Container used to store the Terraform state file
• a Key Vault containing all secrets to allow easy and secure
access
• https://github.com/whiteducksoftware/terraform-scaffold-
for-azure
© white duck GmbH 2021
Questions?
Slides: https://www.slideshare.net/nmeisenzahl
Nico Meisenzahl (Senior Cloud & DevOps Consultant)
Phone: +49 8031 230159 0
Email: nico.meisenzahl@whiteduck.de
Twitter: @nmeisenzahl
LinkedIn: https://www.linkedin.com/in/nicomeisenzahl
Blog: https://meisenzahl.org
© white duck GmbH 2021

More Related Content

PDF
DevOpsCon Berlin: Helm vs Operators – Do I Need to Decide?
PDF
Cloud Native Day: Cloud-native Anwendungsentwicklung im Jahr 2021
PDF
GitLab Commit DevOps: How GitLab Can Save your Kubernetes environment from Be...
PDF
Die Evolution von Container Image Builds
PDF
Azure Rosenheim Meetup: Azure Service Operator
PDF
Continuous Lifecycle: Hijack Kubernetes
PDF
GitHub Actions 101
PDF
azdevcom - Hijack a Kubernetes Cluster
DevOpsCon Berlin: Helm vs Operators – Do I Need to Decide?
Cloud Native Day: Cloud-native Anwendungsentwicklung im Jahr 2021
GitLab Commit DevOps: How GitLab Can Save your Kubernetes environment from Be...
Die Evolution von Container Image Builds
Azure Rosenheim Meetup: Azure Service Operator
Continuous Lifecycle: Hijack Kubernetes
GitHub Actions 101
azdevcom - Hijack a Kubernetes Cluster

What's hot (20)

PDF
Azure Saturday Hamburg: Containerize Your .NET Microservice - the Right Way!
PDF
Hijack a Kubernetes Cluster - a Walkthrough
PDF
Continuous Lifecycle: Enhance Your Compliance and Governance With Policy-Base...
PDF
Virtual GitLab Meetup: How Containerized Pipelines and Kubernetes Can Boost Y...
PDF
GitLab Commit: Enhance your Compliance with Policy-Based CI/CD
PDF
Azure Zürich User Group: Azure Kubernetes Service – more than just a managed ...
PDF
Hijack a Kubernetes Cluster - a Walkthrough
PPTX
FestiveTechCalendar2021 - Have Yourself An​ Azure Container Registry
PDF
Enhance Your Kubernetes CI/CD Pipelines With GitLab & Open Source
PDF
Policy & Governance für Kubernetes
PDF
GitLab Commit: Your Attackers Won't Be Happy! How GitLab Can Help You Secure ...
PDF
The Future of Workflow Automation Is Now - Hassle-Free ARM Template Deploymen...
PDF
Was ist ein Service Mesh und wie funktioniert es?
PDF
GitLab Remote Meetup: Enhance Your Kubernetes CI/CD Pipelines with GitLab & ...
PDF
Docker Rosenheim Meetup: Policy & Governance for Kubernetes
PDF
Virtual Azure Community Day: Azure Kubernetes Service Basics
PDF
DevOps Gathering - How Containerized Pipelines Can Boost Your CI/CD
PDF
Global Azure Bootcamp: Container, Docker & Kubernetes Basics
PDF
DevOpsCon London: How containerized Pipelines can boost your CI/CD
PDF
Monitor Traefik with Prometheus
Azure Saturday Hamburg: Containerize Your .NET Microservice - the Right Way!
Hijack a Kubernetes Cluster - a Walkthrough
Continuous Lifecycle: Enhance Your Compliance and Governance With Policy-Base...
Virtual GitLab Meetup: How Containerized Pipelines and Kubernetes Can Boost Y...
GitLab Commit: Enhance your Compliance with Policy-Based CI/CD
Azure Zürich User Group: Azure Kubernetes Service – more than just a managed ...
Hijack a Kubernetes Cluster - a Walkthrough
FestiveTechCalendar2021 - Have Yourself An​ Azure Container Registry
Enhance Your Kubernetes CI/CD Pipelines With GitLab & Open Source
Policy & Governance für Kubernetes
GitLab Commit: Your Attackers Won't Be Happy! How GitLab Can Help You Secure ...
The Future of Workflow Automation Is Now - Hassle-Free ARM Template Deploymen...
Was ist ein Service Mesh und wie funktioniert es?
GitLab Remote Meetup: Enhance Your Kubernetes CI/CD Pipelines with GitLab & ...
Docker Rosenheim Meetup: Policy & Governance for Kubernetes
Virtual Azure Community Day: Azure Kubernetes Service Basics
DevOps Gathering - How Containerized Pipelines Can Boost Your CI/CD
Global Azure Bootcamp: Container, Docker & Kubernetes Basics
DevOpsCon London: How containerized Pipelines can boost your CI/CD
Monitor Traefik with Prometheus
Ad

Similar to Azure Meetup Hamburg: Production-Ready Terraform Deployments on Azure (20)

PPTX
AzDevCom2021 - Bicep vs Terraform
PPTX
Infrastructure-as-Code (IaC) using Terraform
PDF
GDG Cloud Southlake #8 Steve Cravens: Infrastructure as-Code (IaC) in 2022: ...
PPTX
Infrastructure-as-Code (IaC) Using Terraform (Intermediate Edition)
PDF
Terraform In Action Meap V10 Meap Scott Winkler
PPTX
Terraform on Azure
PPTX
Linode_eBook_Declarative_Cloud_Infrastructure_Management_with_Terraform.pptx
PPTX
Microsoft Azure IaaS and Terraform
PPTX
Alex Magnay - Azure Infrastructure as Code with Hashicorp Terraform
PDF
Infrastructure as Code for Azure: ARM or Terraform?
PDF
Instant download Terraform in Depth (MEAP V01) Robert Hafner pdf all chapter
PPTX
Infrastructure as code, using Terraform
PDF
Terraforming your Infrastructure on GCP
PDF
Oracle Cloud - Infrastruktura jako kód
PDF
An introduction to the Terraform IaC tool
PDF
Oracle Cloud deployment with Terraform
PPTX
Aprovisionamiento multi-proveedor con Terraform - Plain Concepts DevOps day
PPTX
DevOps Training - Introduction to Terraform
PPTX
Terraform Automation in Azure Online Training Institute in Hyderabad.pptx
PDF
Terraform in Depth (MEAP V01) Robert Hafner
AzDevCom2021 - Bicep vs Terraform
Infrastructure-as-Code (IaC) using Terraform
GDG Cloud Southlake #8 Steve Cravens: Infrastructure as-Code (IaC) in 2022: ...
Infrastructure-as-Code (IaC) Using Terraform (Intermediate Edition)
Terraform In Action Meap V10 Meap Scott Winkler
Terraform on Azure
Linode_eBook_Declarative_Cloud_Infrastructure_Management_with_Terraform.pptx
Microsoft Azure IaaS and Terraform
Alex Magnay - Azure Infrastructure as Code with Hashicorp Terraform
Infrastructure as Code for Azure: ARM or Terraform?
Instant download Terraform in Depth (MEAP V01) Robert Hafner pdf all chapter
Infrastructure as code, using Terraform
Terraforming your Infrastructure on GCP
Oracle Cloud - Infrastruktura jako kód
An introduction to the Terraform IaC tool
Oracle Cloud deployment with Terraform
Aprovisionamiento multi-proveedor con Terraform - Plain Concepts DevOps day
DevOps Training - Introduction to Terraform
Terraform Automation in Azure Online Training Institute in Hyderabad.pptx
Terraform in Depth (MEAP V01) Robert Hafner
Ad

More from Nico Meisenzahl (14)

PDF
Cloud-Native & Sustainability: How and Why to Build Sustainable Workloads
PDF
Container Day Security: How to Prevent Your Kubernetes Cluster From Being Hacked
PDF
Festive Tech Calendar: Festive time with AKS networking
PDF
ContainerConf 2022: Hijack Kubernetes
PDF
ContainerConf 2022: Kubernetes is awesome - but...
PDF
KCD Munich 2022: How to Prevent Your Kubernetes Cluster From Being Hacked
PDF
KCD Munich 2022: Hijack a Kubernetes Cluster - a Walkthrough
PDF
Cloud Love Conference: Kubernetes is awesome, but...
PDF
How to Prevent Your Kubernetes Cluster From Being Hacked
PDF
Container Days: Hijack a Kubernetes Cluster - a Walkthrough
PPTX
Hijack a Kubernetes Cluster - a Walkthrough
PDF
Microsoft DevOps Forum 2021 – DevOps & Security
PDF
Azure Service Operator - Provision Your Resources in a Cloud-Native Way
PDF
Effiziente CI/CD-Pipelines – mit den richtigen Tools klappt das
Cloud-Native & Sustainability: How and Why to Build Sustainable Workloads
Container Day Security: How to Prevent Your Kubernetes Cluster From Being Hacked
Festive Tech Calendar: Festive time with AKS networking
ContainerConf 2022: Hijack Kubernetes
ContainerConf 2022: Kubernetes is awesome - but...
KCD Munich 2022: How to Prevent Your Kubernetes Cluster From Being Hacked
KCD Munich 2022: Hijack a Kubernetes Cluster - a Walkthrough
Cloud Love Conference: Kubernetes is awesome, but...
How to Prevent Your Kubernetes Cluster From Being Hacked
Container Days: Hijack a Kubernetes Cluster - a Walkthrough
Hijack a Kubernetes Cluster - a Walkthrough
Microsoft DevOps Forum 2021 – DevOps & Security
Azure Service Operator - Provision Your Resources in a Cloud-Native Way
Effiziente CI/CD-Pipelines – mit den richtigen Tools klappt das

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Spectroscopy.pptx food analysis technology
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Approach and Philosophy of On baking technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Encapsulation theory and applications.pdf
PPTX
MYSQL Presentation for SQL database connectivity
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPT
Teaching material agriculture food technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Electronic commerce courselecture one. Pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Chapter 3 Spatial Domain Image Processing.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Spectroscopy.pptx food analysis technology
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
Approach and Philosophy of On baking technology
Review of recent advances in non-invasive hemoglobin estimation
Advanced methodologies resolving dimensionality complications for autism neur...
Encapsulation theory and applications.pdf
MYSQL Presentation for SQL database connectivity
The AUB Centre for AI in Media Proposal.docx
Building Integrated photovoltaic BIPV_UPV.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
MIND Revenue Release Quarter 2 2025 Press Release
20250228 LYD VKU AI Blended-Learning.pptx
Teaching material agriculture food technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Electronic commerce courselecture one. Pdf

Azure Meetup Hamburg: Production-Ready Terraform Deployments on Azure

  • 1. Production-Ready Terraform Deployments on Azure Azure Meetup Hamburg, July 2021
  • 2. Nico Meisenzahl • Senior Cloud & DevOps Consultant at white duck • Microsoft MVP, Docker Community Leader & GitLab Hero • Container, Kubernetes, Cloud-Native & DevOps © white duck GmbH 2021 Phone: +49 8031 230159 0 Email: nico.meisenzahl@whiteduck.de Twitter: @nmeisenzahl LinkedIn: https://www.linkedin.com/in/nicomeisenzahl Blog: https://meisenzahl.org
  • 3. Agenda • What is Infrastructure as Code and why do we need it? • Get started with Terraform • Demo: Terraform on Azure © white duck GmbH 2021
  • 4. What is Infrastructure as Code? Infrastructure as Code (IaC) is the management and provisioning of infrastructure through code rather than manual processes. © white duck GmbH 2021
  • 5. Infrastructure as Code is… • version controlled through Git • automated through CI/CD • reusable • self-documented • declarative © white duck GmbH 2021
  • 6. Declarative vs imperative © white duck GmbH 2021
  • 7. Why do we need IaC? • to prevent configuration drift • to recover quickly (rollback, restore) • to reproduce errors & test our infrastructure • to reduce costs & time-to-market © white duck GmbH 2021
  • 8. Infrastructure vs. configuration • infrastructure orchestration is used to provision & manage immutable infrastructure like Cloud resources • e.g. provisioning of a Resource Group containing a Function App • with Terraform, ARM Templates, Pulumi, AWS CloudFormation, … • configuration management can be used to configure/maintain mutable resources • e.g. installing or configuring something within a Virtual Machine • With Ansible, Chef, Puppet, Saltstack, … © white duck GmbH 2021
  • 9. What is Terraform? Terraform is an Infrastructure as Code tool that provides a consistent CLI workflow to manage hundreds of cloud services. Terraform codifies cloud APIs into declarative configuration files. © white duck GmbH 2021
  • 10. What is Terraform? • contains of • a CLI • a domain specific language (DSL) • supports hundreds of cloud services • extendable and therefore flexible • is not a configuration tool • introduced and open-sourced by Hashicorp • is defacto the tool of choice © white duck GmbH 2021
  • 11. Terraform Providers • Terraform relies on plugins called "providers" to interact with Cloud resources • Resource types are implemented by a provider • Terraform itself cannot manage any resources • are provided by • Hashicorp (official flag) • Cloud Providers and Third-Party (verified flag) • open-source community (community flag) • yourself J © white duck GmbH 2021
  • 12. Terraform Modules • are “containers” for multiple resources that are used together • are the main way to package and reuse resource configurations • are stored locally (subfolder) or can be shared/published © white duck GmbH 2021
  • 13. Terraform Registry © white duck GmbH 2021
  • 14. Hashicorp Configuration Language - HCL • a DSL (domain specific language) used to describe resources • there is also the Cloud Development Kit (CDK) • supports TypeScript, Python, Java, C#, Golang • early-stage project • https://github.com/hashicorp/terraform-cdk © white duck GmbH 2021
  • 15. HCL sample © white duck GmbH 2021
  • 16. Terraform workflow © white duck GmbH 2021
  • 17. Terraform State • is used to map “real world” resources to your configuration • code à state ß real world • stores Terraform-managed resources • contains all infrastructure and metadata • incl. secrets! • local by default but should be stored remote backend • Terraform Cloud • Azure Storage Account • AWS, GCP, GitLab, … • … © white duck GmbH 2021
  • 18. Terraform CLI © white duck GmbH 2021
  • 19. Terraform workflow © white duck GmbH 2021
  • 20. Production-ready workflow (PR) © white duck GmbH 2021
  • 21. Terraform sample project structure © white duck GmbH 2021
  • 22. Generic Providers • Template Provider • allows injecting variables into config files • https://registry.terraform.io/providers/hashicorp/template/latest • Random Provider • generates random strings, id, integer, passwords • https://registry.terraform.io/providers/hashicorp/random/latest • TLS Provider • used to generate keys and certificates • https://registry.terraform.io/providers/hashicorp/tls/latest • Null Provider • advanced - helps orchestrate tricky behavior or work arounds • https://registry.terraform.io/providers/hashicorp/null/latest © white duck GmbH 2021
  • 23. Terraform providers for Azure • Azure RM provider • https://registry.terraform.io/providers/hashicorp/azurerm/latest • Azure AAD provider • https://registry.terraform.io/providers/hashicorp/azuread/latest • Azure Stack provider • https://registry.terraform.io/providers/hashicorp/azurestack/latest • Azure DevOps provider • https://registry.terraform.io/providers/microsoft/azuredevops/latest • GitHub provider • https://registry.terraform.io/providers/integrations/github/latest © white duck GmbH 2021
  • 24. Generic resources • Data resource • used to retrieve meta data from unmanaged resources • Remote state resource • used to retrieve meta data from “other” projects • https://registry.terraform.io/providers/hashicorp/terraform/latest/ docs/data-sources/remote_state © white duck GmbH 2021
  • 25. Variables • input variables • serves as parameters for a module or project • output variables • child module can use outputs to expose resource attributes • print certain values in the CLI for further usage • local variables • are a convenience feature for assigning a short name to any expression © white duck GmbH 2021
  • 26. Meta arguments & functions • Terraform supports meta arguments like • count, for_each • depends_on, lifecycle • and a variety of functions like • numeric, string, encoding, hash, crypto, … • https://www.terraform.io/docs/language/functions/index.html © white duck GmbH 2021
  • 27. Provisioners • should only be used as a last option • are not declarative! • Terraform supports • file • local_exec • remote_exec • https://www.terraform.io/docs/language/resources/provisioners/i ndex.html © white duck GmbH 2021
  • 28. Environment stages in Terraform • build one project for all stages (DEV, QS/QA, PROD, …) • build it customizable via variables • repositories vs branches • state management via • Terraform “Workspaces” • uses one backend with multiple states • not supported by all backends • customizable backends • different Backend configurations • inject backend details via CLI/Shell © white duck GmbH 2021
  • 29. Terraform vs ARM Templates • Terraform • extendable and therefore flexible • multi-cloud • requires some work to run it production-ready (CI/CD, state) • also supports ARM templates for advanced use-cases • ARM Templates • first-class support on Azure (but also limited to Azure) • “only” Azure resources, no Azure AAD, etc. • easy start with Bicep (https://github.com/Azure/bicep) © white duck GmbH 2021
  • 30. Demo: Terraform on Azure • scaffold a first Terraform project • provision some Azure resources © white duck GmbH 2021
  • 31. Authentication with Azure RM / Azure AD • local Azure CLI • Service Principal with a Client Certificate • Service Principal with a Client Secret • Managed Identity © white duck GmbH 2021
  • 32. Terraform scaffold for Azure • provisions • a service principal used to run Terraform on behalf • a Storage Container used to store the Terraform state file • a Key Vault containing all secrets to allow easy and secure access • https://github.com/whiteducksoftware/terraform-scaffold- for-azure © white duck GmbH 2021
  • 33. Questions? Slides: https://www.slideshare.net/nmeisenzahl Nico Meisenzahl (Senior Cloud & DevOps Consultant) Phone: +49 8031 230159 0 Email: nico.meisenzahl@whiteduck.de Twitter: @nmeisenzahl LinkedIn: https://www.linkedin.com/in/nicomeisenzahl Blog: https://meisenzahl.org © white duck GmbH 2021