azure-dev-docs/hub-spoke-spoke-network.md at main · MicrosoftDocs/azure-dev-docs

title
description
ms.topic
ms.date
ms.custom

Create a spoke network in Azure using Terraform

Learn how to implement two spoke virtual networks (VNets) connected to a hub in a hub-spoke topology.

how-to

08/07/2021

devx-track-terraform

Create a spoke network in Azure using Terraform

[!INCLUDE Terraform abstract]

In this article, you implement two separate spoke networks to demonstrate separation of workloads. The networks share common resources using hub virtual network. Spokes can be used to isolate workloads in their own VNets, managed separately from other spokes. Each workload might include multiple tiers, with multiple subnets connected through Azure load balancers.

In this article, you learn how to:

[!div class=”checklist”]

  • Implement the Spoke VNets in hub-spoke topology
  • Create Virtual machines in the spoke networks
  • Establish virtual network peerings with the hub networks

1. Configure your environment

[!INCLUDE open-source-devops-prereqs-azure-subscription.md]

[!INCLUDE configure-terraform.md]

2. Implement the Terraform code

Two spoke scripts are created in this section. Each script defines a spoke virtual network and a virtual machine for the workload. A peered virtual network from hub to spoke is then created.

  1. Make the example directory created in the first article of this series the current directory.

  2. Create a file named spoke1.tf and insert the following code:

    [!code-terraformmaster]

  3. Create a file named spoke2.tf and insert the following code:

    [!code-terraformmaster]

Troubleshoot Terraform on Azure

Troubleshoot common problems when using Terraform on Azure

Next steps