<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Diogo Moreira</title>
    <description>The latest articles on DEV Community by Diogo Moreira (@diogosmoreira).</description>
    <link>https://dev.to/diogosmoreira</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4099461%2Fa8657a80-51d6-4160-988b-b7906b8b1c74.jpg</url>
      <title>DEV Community: Diogo Moreira</title>
      <link>https://dev.to/diogosmoreira</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/diogosmoreira"/>
    <language>en</language>
    <item>
      <title>How to build an Azure Landing Zone with Terraform (and the mistakes it saves you from)</title>
      <dc:creator>Diogo Moreira</dc:creator>
      <pubDate>Tue, 17 Nov 2026 20:38:22 +0000</pubDate>
      <link>https://dev.to/diogosmoreira/how-to-build-an-azure-landing-zone-with-terraform-and-the-mistakes-it-saves-you-from-1lam</link>
      <guid>https://dev.to/diogosmoreira/how-to-build-an-azure-landing-zone-with-terraform-and-the-mistakes-it-saves-you-from-1lam</guid>
      <description>&lt;p&gt;Every cloud journey starts the same way. Someone creates a subscription, deploys the first application by hand, and it works. Then a second team arrives. Then a third.&lt;/p&gt;

&lt;p&gt;A year later, the same company usually has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;resources in regions nobody approved,&lt;/li&gt;
&lt;li&gt;resource groups nobody owns, and a bill nobody can explain,&lt;/li&gt;
&lt;li&gt;virtual networks with overlapping address ranges that can never be connected,&lt;/li&gt;
&lt;li&gt;a database with a public IP "just for testing",&lt;/li&gt;
&lt;li&gt;and a monthly cost that grows faster than the business.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of these is a disaster on its own. Together, they make every change slow and risky, because everything is already in production.&lt;/p&gt;

&lt;p&gt;After more than 20 years in infrastructure, including scaling cloud platforms for a global e-commerce company, I've learned that the cheapest moment to fix these problems is &lt;strong&gt;before the first workload lands&lt;/strong&gt;. That is what a &lt;strong&gt;landing zone&lt;/strong&gt; is for.&lt;/p&gt;

&lt;p&gt;In this article I'll walk through how to build one with Terraform, the decisions behind each part, and the mistakes it protects you from. All the code is open source:&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://github.com/diogosmoreira84/azure-enterprise-landing-zone" rel="noopener noreferrer"&gt;github.com/diogosmoreira84/azure-enterprise-landing-zone&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a landing zone, really?
&lt;/h2&gt;

&lt;p&gt;A landing zone is the pre-built environment that workloads "land" in. When a new team arrives, the hierarchy, the rules, the network, the logging and the cost controls are already there. Teams move fast; the platform team keeps control.&lt;/p&gt;

&lt;p&gt;Microsoft's Cloud Adoption Framework describes it through &lt;strong&gt;eight design areas&lt;/strong&gt;. You don't need all of them on day one. The reference I built covers the six that matter most for getting started, and leaves identity and billing for later:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Design area&lt;/th&gt;
&lt;th&gt;Covered&lt;/th&gt;
&lt;th&gt;How&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Billing and Entra tenant&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;Decided once per organisation, outside Terraform&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Identity and access&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;A topic for its own article&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Resource organisation&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;Management groups, naming and tagging&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Network topology&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;Hub and spoke, NSGs, optional firewall, private DNS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Security&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;Deny-by-default NSGs, no public IPs in Corp&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Management&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;Central Log Analytics and Activity Log export&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Governance&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;Azure Policy guardrails and budgets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Platform automation&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;Modular Terraform, remote state, CI with security scanning&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Let's go through them in the order I'd build them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Organise with management groups
&lt;/h2&gt;

&lt;p&gt;Management groups are folders above subscriptions. Anything you assign to a management group, like a policy or a role, is inherited by every subscription below it. Get the hierarchy right and you configure governance once, instead of once per subscription.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1vq2q47kp0rcatys4z9n.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1vq2q47kp0rcatys4z9n.jpg" alt="Management group hierarchy: Organisation root with Platform, Landing zones (Corp and Online), Sandbox and Decommissioned" width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The mistake it saves you from:&lt;/strong&gt; building the hierarchy around the org chart. Departments change at every reorganisation. "Internal" versus "internet-facing" doesn't. Organise by the &lt;em&gt;rules a workload needs&lt;/em&gt;, keep it shallow (three or four levels), and always have a place for the exceptions, so nobody has to bend the production rules.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Guardrails with Azure Policy
&lt;/h2&gt;

&lt;p&gt;A guideline is something people forget. A policy is something the platform enforces. I start with three guardrails:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Policy&lt;/th&gt;
&lt;th&gt;Where&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Allowed locations&lt;/td&gt;
&lt;td&gt;Organisation root&lt;/td&gt;
&lt;td&gt;Data residency and a predictable footprint&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Required tags on resource groups&lt;/td&gt;
&lt;td&gt;Organisation root&lt;/td&gt;
&lt;td&gt;Every cost and every incident has an owner&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No public IPs on network interfaces&lt;/td&gt;
&lt;td&gt;Corp&lt;/td&gt;
&lt;td&gt;Internal stays internal&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In Terraform, I look up built-in policies by name instead of hard-coding GUIDs, which keeps the code readable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="s2"&gt;"azurerm_policy_definition_built_in"&lt;/span&gt; &lt;span class="s2"&gt;"allowed_locations"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;display_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Allowed locations"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"azurerm_management_group_policy_assignment"&lt;/span&gt; &lt;span class="s2"&gt;"allowed_locations"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;                 &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"allowed-locations"&lt;/span&gt;
  &lt;span class="n"&gt;management_group_id&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root_management_group_id&lt;/span&gt;
  &lt;span class="n"&gt;policy_definition_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;azurerm_policy_definition_built_in&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;allowed_locations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;

  &lt;span class="n"&gt;parameters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;jsonencode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;listOfAllowedLocations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;allowed_locations&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The mistake it saves you from:&lt;/strong&gt; switching straight to "deny" in an existing environment. You will break deployments on a Friday afternoon. In brownfield subscriptions, start with &lt;strong&gt;audit&lt;/strong&gt;, fix what you find, then enforce.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: One place for logs
&lt;/h2&gt;

&lt;p&gt;When something breaks, or an auditor asks who changed a firewall rule, the answer must be in one place. The landing zone creates a central Log Analytics workspace and sends the subscription &lt;strong&gt;Activity Log&lt;/strong&gt; to it from day one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The mistake it saves you from:&lt;/strong&gt; discovering, during an incident review, that the Activity Log you needed is older than the 90 days Azure keeps by default.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: A network you won't have to rebuild
&lt;/h2&gt;

&lt;p&gt;The landing zone uses a &lt;strong&gt;hub-and-spoke&lt;/strong&gt; topology. Shared network services live in a central hub. Every workload gets its own spoke, peered to the hub.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9vhvnzt8c8upjr23jpc5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9vhvnzt8c8upjr23jpc5.jpg" alt="Hub-and-spoke network: a hub VNet with Firewall, Gateway, Bastion and Private DNS, peered to isolated workload spokes" width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each spoke gets its own subnets, a deny-by-default NSG on every subnet, and, when the firewall is on, a route that sends all outbound traffic through the hub.&lt;/p&gt;

&lt;p&gt;A few lessons I'd tattoo on every platform team:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Plan the address space once, for the whole company.&lt;/strong&gt; Overlapping ranges are the one networking mistake you cannot fix without rebuilding. In the code, the hub subnets are calculated from a single range with &lt;code&gt;cidrsubnet()&lt;/code&gt;, so there's no manual subnet maths to get wrong.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reserve the special subnets on day one.&lt;/strong&gt; Firewall, Gateway and Bastion need exact names and minimum sizes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Peering is not transitive.&lt;/strong&gt; Spoke A can't reach spoke B through the hub unless something routes the traffic. That's the firewall's job.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make expensive things optional.&lt;/strong&gt; Azure Firewall has a significant fixed monthly cost, so it's one variable away, but off by default.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And adding a new workload is data, not code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="n"&gt;spokes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;payments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;address_space&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"10.20.0.0/16"&lt;/span&gt;
    &lt;span class="n"&gt;subnets&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"10.20.1.0/24"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"10.20.2.0/24"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 5: Costs under control from day one
&lt;/h2&gt;

&lt;p&gt;Cost is a design area like any other. Three things go a long way:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Standard tags on everything&lt;/strong&gt;, enforced by policy, so every euro can be traced to a team. Optional tags are missing within weeks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A monthly budget&lt;/strong&gt; with alerts at 50%, 80% and 100%.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A forecast alert&lt;/strong&gt;, which is the one that actually helps: an alert at 100% of &lt;em&gt;actual&lt;/em&gt; spend tells you about money that's already gone.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 6: Treat the platform like a product
&lt;/h2&gt;

&lt;p&gt;A landing zone isn't a one-off project. It's a product the platform team runs and evolves, so it deserves the same engineering discipline:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Remote state&lt;/strong&gt; in a hardened storage account: TLS 1.2, no public blobs, shared keys disabled (Entra ID only), versioning and soft delete. The repository includes a small &lt;code&gt;bootstrap/&lt;/code&gt; to create it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One module per responsibility&lt;/strong&gt;: governance, logging, connectivity, cost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validation on inputs&lt;/strong&gt; that can be wrong, like CIDR ranges and naming prefixes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CI on every pull request&lt;/strong&gt;: &lt;code&gt;terraform fmt&lt;/code&gt;, &lt;code&gt;validate&lt;/code&gt;, TFLint and a Checkov security scan. Every skipped security check is skipped on purpose, with the reason written next to the resource.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What a production landing zone adds
&lt;/h2&gt;

&lt;p&gt;This reference shows the patterns. For a real company, you'd add identity (Entra ID groups mapped to roles, Privileged Identity Management, break-glass accounts), &lt;strong&gt;subscription vending&lt;/strong&gt; so every workload gets its own subscription, separate platform subscriptions, Microsoft Defender for Cloud, and hybrid connectivity. For large estates, Microsoft's own Azure Landing Zones Terraform modules are a solid, supported baseline.&lt;/p&gt;

&lt;p&gt;But the principles stay the same, and they are the part that matters: &lt;strong&gt;decide the rules before the workloads arrive, enforce them in code, and make the right thing the easy thing.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Build the foundations before the first workload lands.&lt;/strong&gt; Fixing them later means changing things that are already in production.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Organise by the rules workloads need&lt;/strong&gt;, not by the org chart, and keep the hierarchy shallow.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enforce, don't recommend.&lt;/strong&gt; Policies, tags and budgets only work when the platform applies them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Plan the network once.&lt;/strong&gt; Overlapping address ranges are the mistake you can't undo.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run the landing zone like a product&lt;/strong&gt;, with code review, CI and security scanning.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;The full code, with a step-by-step guide, is here:&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://github.com/diogosmoreira84/azure-enterprise-landing-zone" rel="noopener noreferrer"&gt;github.com/diogosmoreira84/azure-enterprise-landing-zone&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With the default settings it costs very little to run, so you can deploy it in a personal subscription and explore.&lt;/p&gt;

&lt;p&gt;In the next articles of this series I'll go deeper into each area, starting with &lt;strong&gt;Azure Policy: how to roll out guardrails without breaking production&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;What was the first thing that went wrong in your cloud environment because the foundations weren't there? I'd love to hear it in the comments.&lt;/p&gt;

</description>
      <category>azure</category>
      <category>terraform</category>
      <category>devops</category>
      <category>cloud</category>
    </item>
  </channel>
</rss>
