r/Terraform Cloud Engineer | Youtube @adeelautomates Jul 20 '26

Discussion Learn Infrastructure as Code in Azure with Terraform - Part 2

The follow-up to my Beginner episode I posted here is finally out.

Part 2 of this planned Azure Terraform series shifts away from simply deploying resources and focuses more on programmatically approaching Terraform.

Topics covered include:

  • Functions
  • Conditionals
  • Operators
  • Loops
  • Dynamic Blocks
  • For Expressions & Splat
  • Validations (including Check Blocks and Pre/Post Conditions)
  • Nested Types (including complex variable types)
  • Provider Aliases (deploy across multiple Azure subscriptions)
  • KISS vs DRY
  • And much more...

Rather than jumping between unrelated examples, everything is built around a single Azure project so each concept is introduced naturally as the deployment grows in complexity.

We definitely over-engineer this project just to teach these programming concepts, but understanding them will help you write much more flexible & dynamic Infrastructure as Code.

With that, our roadmap continues!

  • Beginner Episode : Understand Terraform (learn the foundations and core concepts that make Terraform work)
  • Intermediate Episode : Program Terraform (use loops, functions, conditionals, dynamic blocks, etc)
  • Advanced Episode : Structure Terraform (introduce modules, remote state in azure storage, workspaces, imports, etc)
  • Project Episode(s): Build Azure Projects (Less about Terraform itself & more about building interesting architectures in Azure)
  • Professional Episode : Operationalize Terraform (use GitHub, CI/CD, pull requests, state management, and deployment workflows to work in a team environment)

Link to Episode: https://www.youtube.com/watch?v=QwXqLAvmKac

11 Upvotes

7 comments sorted by

1

u/r1ckm4n Jul 20 '26

I fucking hated doing TF with Azure.

2

u/g-nice4liief Jul 20 '26

Yeah exactly. I also hate it, but with proxmox. Makes terraforming much harder. Have you also had problems terraforming using AWS?

/s

1

u/r1ckm4n Jul 20 '26

My beef with Azure is AZ parity. Even within the same region, there are things that dont simply exist, or there is a value that simply isnt available, so it makes templating services a real pain in the ass. That, and importing already existing resources is a real pain that I havent experienced with other cloud providers.

Azure's TF support is getting slightly better, but it still has a ways to go. I find that any external IaC tool, terraform included, is a second class citizen on Azure.

4

u/AdeelAutomates Cloud Engineer | Youtube @adeelautomates Jul 20 '26

Sorry you feel that way. It's what keeps the lights on at my house :P

3

u/BigUziNoVertt Jul 20 '26

What’s the azurerm resource for light bulbs?

5

u/AdeelAutomates Cloud Engineer | Youtube @adeelautomates Jul 20 '26 edited Jul 20 '26
resource "azurerm_light_bulb" "my_lights" {
  for_each = local.light_bulbs
  name = "light-${local.region_codes[each.value.region]}-001"
  location   = each.value.region
  brightness = each.value.brightness
  dynamic "schedule" {
    for_each = lookup(each.value, "schedules", [])
    content {
      time  = schedule.value.time
      state = schedule.value.state
    }
  }
}

Source : https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/light_bulb