I Built an Azure Hub-and-Spoke Landing Zone with Terraform. Here's What Broke.

Table of Contents
Over the last couple of weeks I built an Azure landing zone from scratch: a hub-and-spoke network, private endpoints, policy guardrails and a deployment pipeline with no stored secrets. Everything is in Terraform, and the code is on GitHub.
This isn’t a step-by-step tutorial. It’s what I built, how I proved it works, and what went wrong along the way, because the problems taught me more than the parts that worked first time.
What I built #
- A hub VNet holding the shared services: Azure Firewall (Basic), Azure Bastion, a central Log Analytics workspace and private DNS zones.
- Two spoke VNets, prod and dev, peered to the hub. A route table on each workload subnet sends
0.0.0.0/0to the firewall, so all outbound and spoke-to-spoke traffic is inspected centrally. - Key Vault and Storage with private endpoints and public network access disabled.
- Governance as code: Azure Policy for allowed regions, required tags and no public IPs in the spokes, plus a least-privilege custom RBAC role.
- A GitHub Actions pipeline: every pull request gets a Checkov security scan and a Terraform plan posted as a comment; merging to
maindeploys after a manual approval. GitHub authenticates to Azure with OIDC, so there’s no client secret anywhere.
The firewall, Bastion and test VMs sit behind feature toggles in terraform.tfvars. The idle baseline costs under £1 a month; a full test session costs around 60p an hour.
Proving it works #
I didn’t want “it deployed” to be the evidence. So I ran tests from inside the network:
| Test | Result |
|---|---|
curl ifconfig.me from the prod VM | Returned the firewall’s public IP, not the VM’s |
| Request to a site not on the allow list | Blocked, and logged as a deny |
| Prod VM to dev VM on port 22 | Timed out: the spokes are isolated |
| Key Vault DNS lookup from my laptop | Public IP, with public access disabled |
| Same lookup from the prod VM | 10.1.2.4, the private endpoint |
| Creating a VNet in East US | RequestDisallowedByPolicy |
That DNS result is my favourite. The vault’s name never changes. What changes is the answer you get, depending on where you ask from.
What broke, and what it taught me #
1. “Out of stock” vs “over your limit” #
My first test VMs failed with SkuNotAvailable: UK South had no capacity for Standard_B1s on my subscription. I switched size, and the next attempt failed differently: my vCPU quota for that VM family was zero.
Those are two different problems. Capacity is Azure being out of stock; quota is your subscription’s spending limit for a VM family. Two commands showed me which sizes I could actually use:
az vm list-skus -l uksouth --size Standard_D2s_v3 --query '[].restrictions'
az vm list-usage -l uksouth -o table
I also made the VM size a variable, so the next change is one line instead of an edit inside a module.
2. The Bastion Terraform forgot about #
Azure Bastion took longer than Terraform’s 30-minute create timeout. Terraform gave up with context deadline exceeded, but Azure carried on and finished building it. Because the create never completed from Terraform’s point of view, the Bastion wasn’t in state.
I found out at teardown: Terraform tried to delete the Bastion’s public IP and failed, because the Bastion it didn’t know about was still using it. An orphaned resource like that keeps billing quietly. I deleted it with the Azure CLI and re-ran the destroy (terraform import is the other option if you want to keep it).
Two habits came out of this: never interrupt a running apply, and always check the portal after a teardown.
3. The OIDC subject that didn’t match #
The first pipeline run failed at terraform init:
AADSTS700213: No matching federated identity record found for presented assertion subject
'repo:PremKPG@<owner-id>/azure-hub-spoke-landing-zone@<repo-id>:pull_request'
My federated credential trusted repo:PremKPG/azure-hub-spoke-landing-zone:pull_request. Newer GitHub repositories include immutable numeric IDs in the subject, which stops a deleted-and-recreated repository with the same name from inheriting your Azure access. The fix was updating both federated credentials to match the presented subject exactly. The error message told me exactly what to change; I just had to read it properly.
4. Key Vault has two locks #
When I opened the vault’s secrets in the portal to prove public access was blocked, I got an RBAC error instead of a network error. My account had no data-plane role, so the identity check failed before the network check was even reached. Two independent controls: a nice accidental demonstration of defence in depth.
5. Required checks that never ran #
Once main required the plan and scan checks, a README-only pull request sat on “Expected — waiting for status” forever. The plan workflow only triggered on changes to infra/ and modules/, so the required checks never reported. Running the plan workflow on every pull request fixed it.
Fix it, suppress it, or accept it #
Checkov’s first scan found 10 issues. Rather than fix everything or ignore everything, I triaged each one:
- Fixed: storage soft delete, and NSGs on the private endpoint subnets. That one hid a gotcha: NSGs are ignored for private endpoints unless
private_endpoint_network_policiesis enabled on the subnet. - Not applicable: an NSG on
AzureFirewallManagementSubnet, which Azure doesn’t support. - Accepted for a lab, with the reason written inline: LRS replication, Microsoft-managed keys, and Key Vault purge protection, which can never be turned off once enabled.
Then I switched Checkov to soft_fail: false. Any new, untriaged finding now blocks the pull request.
What I’d do next #
- Replace the pipeline identity’s User Access Administrator role with a custom role scoped to exactly what it needs
- Add an AKS spoke with egress through the firewall
- Add Azure DNS Private Resolver for hybrid name resolution
- Split state per environment and add
terraform testfor the modules
The full code, screenshots and design decisions are in the repository. If you’ve built something similar and would have done it differently, I’d genuinely like to hear how.