Skip to content

Commit 0b76ca5

Browse files
authored
Merge pull request #291927 from LiSeda/LS-tfexpress
LS_quickstart-create-expressroute-vnet-terraform.md
2 parents 56293d4 + c43b4b8 commit 0b76ca5

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed

articles/expressroute/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
- name: Create an ExpressRoute circuit - ARM template
2121
displayName: Resource Manager
2222
href: quickstart-create-expressroute-vnet-template.md
23+
- name: Create an ExpressRoute circuit - Terraform
24+
href: quickstart-create-expressroute-vnet-terraform.md
2325
expanded: true
2426
- name: Tutorials
2527
items:
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
---
2+
title: 'Quickstart: Configure an Azure virtual network gateway with Terraform'
3+
description: In this quickstart, you create a resource group, a virtual network, a subnet for the gateway, a public IP for the gateway, an Azure ExpressRoute gateway, an ExpressRoute circuit, and an ExpressRoute circuit peering in Azure.
4+
ms.topic: quickstart
5+
ms.date: 01/29/2025
6+
ms.custom: devx-track-terraform
7+
ms.service: azure-virtual-network
8+
author: duongau
9+
ms.author: duau
10+
#customer intent: As a Terraform user, I want to see how to create a resource group, a virtual network, a subnet for the gateway, a public IP for the gateway, an Azure ExpressRoute gateway, an ExpressRoute circuit, and an ExpressRoute circuit peering in Azure.
11+
content_well_notification:
12+
- AI-contribution
13+
---
14+
15+
# Quickstart: Configure an Azure virtual network gateway with Terraform
16+
17+
In this quickstart, you use Terraform to create an Azure ExpressRoute circuit with *Equinix* as the service provider. The circuit uses a *Standard SKU* with a bandwidth of *50 Mbps* and the peering location of *Washington, D.C.* Private peering is enabled with a primary and secondary subnet of *192.168.10.16/30* and *192.168.10.20/30*, respectively. The script also creates a virtual network and a *HighPerformance ExpressRoute gateway*.
18+
19+
:::image type="content" source="media/expressroute-howto-circuit-portal-resource-manager/environment-diagram.png" alt-text="Diagram of an Azure ExpressRoute circuit deployment environment using Bicep." lightbox="media/expressroute-howto-circuit-portal-resource-manager/environment-diagram.png":::
20+
21+
[!INCLUDE [About Terraform](~/azure-dev-docs-pr/articles/terraform/includes/abstract.md)]
22+
23+
In this article, you learn how to:
24+
25+
> [!div class="checklist"]
26+
> * Create an Azure resource group with a unique name.
27+
> * Create a virtual network with a subnet for the gateway.
28+
> * Create a public IP for the gateway.
29+
> * Create an ExpressRoute circuit and configure private peering.
30+
> * Output the resource group name, ExpressRoute circuit ID, gateway name, gateway IP, and the service key.
31+
32+
## Prerequisites
33+
34+
- Create an Azure account with an active subscription. You can [create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
35+
36+
- [Install and configure Terraform](/azure/developer/terraform/quickstart-configure).
37+
38+
## Implement the Terraform code
39+
40+
> [!NOTE]
41+
> The sample code for this article is located in the [Azure Terraform GitHub repo](https://github.com/Azure/terraform/tree/master/quickstart/101-azure-expressroute). You can view the log file containing the [test results from current and previous versions of Terraform](https://github.com/Azure/terraform/tree/master/quickstart/101-azure-expressroute/TestRecord.md).
42+
>
43+
> See more [articles and sample code showing how to use Terraform to manage Azure resources](/azure/terraform).
44+
45+
1. Create a directory in which to test and run the sample Terraform code, and make it the current directory.
46+
47+
1. Create a file named `main.tf`, and insert the following code:
48+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-azure-expressroute/main.tf":::
49+
50+
1. Create a file named `outputs.tf`, and insert the following code:
51+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-azure-expressroute/outputs.tf":::
52+
53+
1. Create a file named `providers.tf`, and insert the following code:
54+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-azure-expressroute/providers.tf":::
55+
56+
1. Create a file named `variables.tf`, and insert the following code:
57+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-azure-expressroute/variables.tf":::
58+
59+
## Initialize Terraform
60+
61+
[!INCLUDE [terraform-init.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-init.md)]
62+
63+
## Create a Terraform execution plan
64+
65+
[!INCLUDE [terraform-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan.md)]
66+
67+
## Apply a Terraform execution plan
68+
69+
[!INCLUDE [terraform-apply-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-apply-plan.md)]
70+
71+
## Verify the results
72+
73+
### [Azure CLI](#tab/azure-cli)
74+
75+
1. Get the Azure resource group name.
76+
77+
```bash
78+
resource_group_name=$(terraform output -raw resource_group_name)
79+
```
80+
81+
1. Get the gateway name.
82+
83+
```bash
84+
gateway_name=$(terraform output -raw gateway_name)
85+
```
86+
87+
1. Run [`az network vnet-gateway show`](/cli/azure/network/vnet-gateway#az-network-vnet-gateway-show) to view the Azure virtual network gateway.
88+
89+
```azurecli
90+
az network vnet-gateway show --name $gateway_name --resource-group $resource_group_name
91+
```
92+
93+
### [Azure PowerShell](#tab/azure-powershell)
94+
95+
1. Get the Azure resource group name.
96+
97+
```powershell
98+
$resource_group_name=$(terraform output -raw resource_group_name)
99+
```
100+
101+
1. Get the gateway name.
102+
103+
```powershell
104+
$gateway_name=$(terraform output -raw gateway_name)
105+
```
106+
107+
1. Run [`Get-AzVirtualNetworkGateway`](/powershell/module/az.network/get-azvirtualnetworkgateway#:~:text=Example%202:%20Get%20a%20Virtual%20Network%20Gateway) to view the Azure virtual network gateway.
108+
109+
```azurepowershell
110+
Get-AzVirtualNetworkGateway -Name $gateway_name -ResourceGroupName $resource_group_name
111+
```
112+
113+
---
114+
115+
## Clean up resources
116+
117+
[!INCLUDE [terraform-plan-destroy.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan-destroy.md)]
118+
119+
## Troubleshoot Terraform on Azure
120+
121+
[Troubleshoot common problems when using Terraform on Azure](/azure/developer/terraform/troubleshoot).
122+
123+
## Next steps
124+
125+
> [!div class="nextstepaction"]
126+
[See more articles about Azure virtual network gateway.](/search/?terms=Azure%20virtual%20network%20gateway%20and%20terraform)
127+
128+
To learn how to link a virtual network to a circuit, continue to the ExpressRoute tutorials.
129+
130+
> [!div class="nextstepaction"]
131+
> [ExpressRoute tutorials](expressroute-howto-linkvnet-portal-resource-manager.md)

0 commit comments

Comments
 (0)