
Explore how to develop infrastructure on Azure using Terraform in Cloud Shell. Learn to convert systems to code with HCL and leverage vendor-agnostic providers for cloud and on-prem automation.
Log in to Azure Cloud Shell, choose bash, create a new resource group and a unique storage account with a file share, then load the shell where Terraform is preinstalled.
Clone the Terraform on Azure repository into your cloud environment to access all course examples and start creating infrastructure with Terraform.
Learn the four core Terraform commands, plan, apply, destroy, and the basics, to start building infrastructure in Azure and deploy a virtual machine using Azure Cloud Shell.
Learn how Terraform configuration files in Azure Cloud Shell use resource blocks to define resource groups and other resources, using HashiCorp configuration language and expressions.
Explore how the Azure provider authenticates Terraform deployments, via Azure CLI login, service principals with environment variables, and managed identities, and how versioning and multi-subscription configurations manage deployments.
Initialize terraform for Azure by setting up the backend and downloading the Azure provider. Run terraform init to install and lock provider versions via the terraform lock file.
Preview the resource group deployment with terraform plan, then apply to deploy and destroy to tear it down, observing the execution plan and one resource added.
Learn how interpolation in Terraform enables passing resource group name and location to Azure resources, allowing virtual network and subnet blocks to reuse values without hard coding.
Build a terraformed configuration to deploy a Windows Server 2016 Datacenter VM in Azure, including resource group, virtual network, subnet, network interface, and size standard.
Deploy an Azure Windows VM with Terraform by adding a network interface block, interpolating location and IDs, and running init and apply to provision, plan, and destroy when done.
Explore how Terraform state works and why tracking it matters, examine the state file's inner workings with Azure, and learn effective strategies for collaborative state management.
Terraform uses a declarative configuration to specify Azure resources and provisions them, enabling scalable cloud management; the state file tracks dependencies and removal order for accurate destruction.
Examine how Terraform state files act as a database linking configurations to Azure resources, manage sensitive metadata, and guide plan, apply, and resource destruction with proper labeling and order.
Terraform refresh compares state file with Azure resources, updates state, and detects drift in subnet ip schemes. Avoid editing state in production and rely on plans and remote state.
Master remote state with Azure storage by enabling state locking, using an Azure RM backend with a storage account, container, and key, plus versioning for history.
Learn to use Terraform outputs to share network data across separated state files in large Azure environments, define output blocks with descriptions and values, and leverage remote state data.
Implement remote state for your Terraform server configuration by creating an Azure storage account and blob container, configuring the backend in the main tf file, and reviewing the solution.
Add a backend block to enable remote state for the server deployment, storing it in an Azure storage container for secure, versioned state and enforcing the portal golden rule.
Learn how Terraform variables boost the reusability of infrastructure's code by enabling dynamic configurations for networking, storage, and compute.
Explore the fundamentals of Terraform variables, including string and list types, with solid descriptions and defaults, and learn to interpolate these variables in the main configuration for Azure networking.
Explore how to deploy variables in Terraform on Azure 2021 using three input methods—tfvars file, dash var, and environment variables formatted as TF_VAR_—and see values propagate into resources.
Explore maps and objects in Terraform to create dynamic configurations using lookup and location-based defaults. Learn about the sensitive flag in Terraform 14 for the password variable.
Convert configuration to Terraform variables, defining os, storage account type map, application string, location, admin username and password (sensitive), vnet and subnet address spaces, and vm size string for deployments.
Explore reusable Terraform configurations by parameterizing resources with variables, learn variable types like strings, maps, lists, and objects, and master input methods using apply, tfvars files, and environment variables.
Discover how Terraform modules reduce duplication by building reusable infrastructure components like SQL servers and virtual machines, enabling safe changes and sharing configurations.
Learn how to use Terraform modules to define a storage account in a modules folder, pass variables (name, rg, location), and apply the configuration with a module block.
Learn how Terraform outputs pass the network security group module's ID to the root configuration, enabling VNet and subnet associations in Azure deployments.
Explore organizing Terraform modules for Azure by choosing mono-repo vs multi-repo structures, sourcing modules from GitHub or the terraformed registry, and using versioned refs to roll out updates.
Develop a Terraform module for Azure Windows Server deployment with a providers block, accepting subnet_id, resource_group_name, location, server_name, vm_size, admin_username, admin_password, and OS object image details.
Deploy an Azure Windows virtual machine using a Terraform module, configure the network interface and inputs like server name, location, resource group, subnet, and OS image, then init and apply.
Explore advanced patterns in the HCO or Corp configuration language, including loops, conditional logic, and scaling resources, to bake logic into Terraform configurations.
Explore built-in functions in Terraform on Azure, including lower, max, mean, split, element, coalesce, length, and file, and use custom data with datasource template files for Azure Windows VM.
Use terraform conditions with an if-then-else to set the resource group location from a location variable, defaulting to south central US, and see East US deployment in the plan.
Learn to use for expressions in Terraform on Azure to loop subnets from a virtual network, transform names to lowercase, and output a mapped, filtered list.
Learn how terraform on azure uses count to scale resource groups with indexed names, and control optional resources like boot diag storage via conditional count and for each.
Use the Terraform for_each loop on a map variable to create multiple network security group rules, using each.key as priority and each.value as the port.
Scale out a hub and spoke network with for_each and nested loops. Auto-create hub-spoke pairings and verify with the tfvars file and plan.
Turn a security rule block into a dynamic block using dynamic and a for_each loop over a list of NSG rule objects, enabling a fully dynamic NSG configuration.
Create the Windows server module with a public IP and network security group, and deploy a PowerShell script via custom data and the Azure custom script extension.
Deploy a Windows server on Azure using a Terraform module that attaches a NSG and public IP, with base64-encoded custom data and a custom script extension.
Learn to manage Azure infrastructure with modular, versioned Terraform, using remote state and source control, treat infrastructure like microservices, keep configurations simple, and leverage the Terraform Registry for reusable modules.
Learn how to create production-grade Azure Infrastructure Code using Terraform in this project-focused hands-on course. Follow along as you learn Terraform and put theory into practice by solving challenges.
We go over what Terraform is and why it’s a highly sought-after skillset. We’ll also go over how to set up Azure CloudShell so we can dive right into developing with Terraform in Azure straight away.
In the first section you'll learn:
What is Terraform?
Getting Started with Azure CloudShell
How to setup your projects to follow along
Learn the fundamentals of Terraform by creating a configuration file and deploying resources into Azure. We’ll also explore the most common ways to authenticate with Azure using the Azure Provider and discuss creating resource dependencies within the Terraform configuration.
Here's what you'll learn about Terraform Configurations:
Terraform Configuration Files
Authenticating with the Azure Provider
Terraform Init, Plan, and Apply
Using Interpolation within Terraform Configurations
Understanding how Terraform state works is a critical component for building Terraform solutions, which is why we’ll be going deep into how the state file keeps track of changes made with Terraform.
Here's what you'll learn about Terraform State:
Why does Terraform need to keep track of state
Examine the inter-workings of the state file
Storing the state file centrally using remote state
Retrieve output from Terraform state
Variables allow Terraform modules to take in input making configuration files dynamic. Infrastructure code can be templatized and re-used throughout different environments.
Here's what you'll learn about Terraform Variables:
Create variable blocks in Terraform configurations
Input values into Terraform configurations using several methods
Learn about the common variable types
Terraform modules split up infrastructure into small, testable components that make it easy for infrastructure developers to introduce changes in small amounts. Learn how to easily create modules and use them with source control.
Here's what you'll learn about Terraform Modules:
Create a module
Pass data between modules
Learn how to use modules from GitHub
Learn about the Terraform Registry
HCL is a functional language that allows infrastructure developers to create loops and conditional logic within Terraform code. This allows a high levels of abstraction to be created for deploying infrastructure.
Here's what you'll learn about HCL:
Functions, conditions, loops and expressions
Dynamic blocks within Terraform resource blocks
Creating resources that scale with count