Skip to content

Commit 05ff598

Browse files
added scenario 2 sample (Azure#282)
* added scenario 2 sample * added additional module for AVS pc * Updated routeserver and gateway modules with tags * added firewall export * corrected module naming error * corrected module naming error * added globalreach module
1 parent d772f7b commit 05ff598

File tree

36 files changed

+1720
-29
lines changed

36 files changed

+1720
-29
lines changed

terraform/modules/avs_azure_firewall_w_log_analytics/outputs.tf

+4
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ output "firewall_policy_name" {
2020

2121
output "firewall_policy_id" {
2222
value = azurerm_firewall_policy.avs_base_policy.id
23+
}
24+
25+
output "firewall_rg_name" {
26+
value = var.rg_name
2327
}

terraform/modules/avs_expressroute_gateway/main.tf

+2-12
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ resource "azurerm_public_ip" "gatewaypip" {
44
location = var.rg_location
55
allocation_method = "Dynamic"
66
sku = "Basic" #required for an ultraperformance gateway
7+
tags = var.tags
78
}
89

910
resource "azurerm_virtual_network_gateway" "gateway" {
1011
name = var.expressroute_gateway_name
1112
resource_group_name = var.rg_name
1213
location = var.rg_location
14+
tags = var.tags
1315

1416
type = "ExpressRoute"
1517
sku = var.expressroute_gateway_sku
@@ -22,18 +24,6 @@ resource "azurerm_virtual_network_gateway" "gateway" {
2224
}
2325
}
2426

25-
resource "azurerm_virtual_network_gateway_connection" "avs" {
26-
name = var.express_route_connection_name
27-
location = var.rg_location
28-
resource_group_name = var.rg_name
29-
enable_bgp = true
30-
31-
type = "ExpressRoute"
32-
virtual_network_gateway_id = azurerm_virtual_network_gateway.gateway.id
33-
express_route_circuit_id = var.express_route_id
34-
authorization_key = var.express_route_authorization_key
35-
}
36-
3727
#############################################################################################
3828
# Telemetry Section - Toggled on and off with the telemetry variable
3929
# This allows us to get deployment frequency statistics for deployments

terraform/modules/avs_expressroute_gateway/variables.tf

+3-13
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,9 @@ variable "gateway_subnet_id" {
2929
description = "The full resource id for the subnet where the bastion will be deployed"
3030
}
3131

32-
variable "express_route_connection_name" {
33-
type = string
34-
description = "Azure resource name for the express_route connection to the AVS private cloud"
35-
}
36-
37-
variable "express_route_id" {
38-
type = string
39-
description = "Azure resource id for the AVS express_route"
40-
}
41-
42-
variable "express_route_authorization_key" {
43-
type = string
44-
description = "AVS private cloud express route authorization key"
32+
variable "tags" {
33+
type = map(string)
34+
description = "List of the tags that will be assigned to each resource"
4535
}
4636

4737
#################################################################
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#This is a template file for the module
2+
#Items that are bracketed are typically resource links to other module output
3+
expressroute_pip_name = "AVS_EXR_PIP"
4+
expressroute_gateway_name = "AVS_EXR_GW"
5+
expressroute_gateway_sku = "Standard"
6+
rg_name = "AVS_Sample_RG"
7+
rg_location = "Southeast Asia"
8+
gateway_subnet_id = "<resource_id_of_the_gateway_subnet>"
9+
express_route_connection_name = "AVS_EXR_Connection"
10+
express_route_id = "<resource_id_of_the_AVS_expressroute>"
11+
express_route_authorization_key = "<authorization_key_of_the_AVS>"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
resource "azurerm_public_ip" "gatewaypip" {
2+
name = var.expressroute_pip_name
3+
resource_group_name = var.rg_name
4+
location = var.rg_location
5+
allocation_method = "Dynamic"
6+
sku = "Basic" #required for an ultraperformance gateway
7+
}
8+
9+
resource "azurerm_virtual_network_gateway" "gateway" {
10+
name = var.expressroute_gateway_name
11+
resource_group_name = var.rg_name
12+
location = var.rg_location
13+
14+
type = "ExpressRoute"
15+
sku = var.expressroute_gateway_sku
16+
17+
ip_configuration {
18+
name = "default"
19+
public_ip_address_id = azurerm_public_ip.gatewaypip.id
20+
private_ip_address_allocation = "Dynamic"
21+
subnet_id = var.gateway_subnet_id
22+
}
23+
}
24+
25+
resource "azurerm_virtual_network_gateway_connection" "avs" {
26+
name = var.express_route_connection_name
27+
location = var.rg_location
28+
resource_group_name = var.rg_name
29+
enable_bgp = true
30+
31+
type = "ExpressRoute"
32+
virtual_network_gateway_id = azurerm_virtual_network_gateway.gateway.id
33+
express_route_circuit_id = var.express_route_id
34+
authorization_key = var.express_route_authorization_key
35+
}
36+
37+
#############################################################################################
38+
# Telemetry Section - Toggled on and off with the telemetry variable
39+
# This allows us to get deployment frequency statistics for deployments
40+
# Re-using parts of the Core Enterprise Landing Zone methodology
41+
#############################################################################################
42+
locals {
43+
#create an empty ARM template to use for generating the deployment value
44+
telem_arm_subscription_template_content = <<TEMPLATE
45+
{
46+
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
47+
"contentVersion": "1.0.0.0",
48+
"parameters": {},
49+
"variables": {},
50+
"resources": [],
51+
"outputs": {
52+
"telemetry": {
53+
"type": "String",
54+
"value": "For more information, see https://aka.ms/alz/tf/telemetry"
55+
}
56+
}
57+
}
58+
TEMPLATE
59+
module_identifier = lower("avs_expressroute_gateway")
60+
telem_arm_deployment_name = "${lower(var.guid_telemetry)}.${substr(local.module_identifier, 0, 20)}.${random_string.telemetry.result}"
61+
}
62+
63+
#create a random string for uniqueness
64+
resource "random_string" "telemetry" {
65+
length = 4
66+
special = false
67+
upper = false
68+
lower = true
69+
}
70+
71+
resource "azurerm_subscription_template_deployment" "telemetry_core" {
72+
count = var.module_telemetry_enabled ? 1 : 0
73+
74+
name = local.telem_arm_deployment_name
75+
location = var.rg_location
76+
template_content = local.telem_arm_subscription_template_content
77+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
output "expressroute_gateway_id" {
2+
value = azurerm_virtual_network_gateway.gateway.id
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### General
2+
3+
* Description: This module creates a new ExpressRoute gateway in an existing VNet and then creates the AVS expressRoute connection using a previously generated ExpressRoute authorization key. The existing VNet requires that an appropriately sized GatewaySubnet exists and is used for the deployment. Resource ID inputs are usually outputs from other modules, but can be input as the full resource ID string.
4+
5+
* The module leverages variables for naming and common values to be modified as part of the deployment.
6+
7+
* A tfvars template file has been included for use if implementing this module as a standalone deployment.
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#################################################################
2+
# module variables
3+
#################################################################
4+
variable "expressroute_pip_name" {
5+
type = string
6+
description = "Azure resource name assigned to the expressroute public ip"
7+
}
8+
variable "expressroute_gateway_name" {
9+
type = string
10+
description = "Azure resource name assigned to the AVS expressroute gateway instance"
11+
}
12+
variable "expressroute_gateway_sku" {
13+
type = string
14+
description = "The sku for the AVS expressroute gateway"
15+
default = "Standard"
16+
}
17+
18+
variable "rg_name" {
19+
type = string
20+
description = "Resource Group Name where the expressroute gateway and the associated public ip are being deployed"
21+
}
22+
variable "rg_location" {
23+
type = string
24+
description = "Resource Group location"
25+
default = "westus2"
26+
}
27+
variable "gateway_subnet_id" {
28+
type = string
29+
description = "The full resource id for the subnet where the bastion will be deployed"
30+
}
31+
32+
variable "express_route_connection_name" {
33+
type = string
34+
description = "Azure resource name for the express_route connection to the AVS private cloud"
35+
}
36+
37+
variable "express_route_id" {
38+
type = string
39+
description = "Azure resource id for the AVS express_route"
40+
}
41+
42+
variable "express_route_authorization_key" {
43+
type = string
44+
description = "AVS private cloud express route authorization key"
45+
}
46+
47+
#################################################################
48+
# telemetry variables
49+
#################################################################
50+
variable "module_telemetry_enabled" {
51+
type = bool
52+
description = "toggle the telemetry on/off for this module"
53+
default = true
54+
}
55+
56+
variable "guid_telemetry" {
57+
type = string
58+
description = "guid used for telemetry identification. Defaults to module guid, but overrides with root if needed."
59+
default = "0f9a8adc-9d37-40b3-aaed-ab34b95cf6dd"
60+
}
61+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
gr_connection_name = "test_gr_connection"
2+
private_cloud_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/privatecloudrg/providers/Microsoft.AVS/privateClouds/privatecloudname"
3+
gr_remote_auth_key = "00000000-0000-0000-0000-000000000000"
4+
gr_remote_expr_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/expressrouterg/providers/Microsoft.Network/expressRouteCircuits/expressroutename"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
resource "azapi_resource" "globalreach_connections" {
2+
type = "Microsoft.AVS/privateClouds/globalReachConnections@2022-05-01"
3+
name = var.gr_connection_name
4+
parent_id = var.private_cloud_id
5+
body = jsonencode({
6+
properties = {
7+
authorizationKey = var.gr_remote_auth_key
8+
peerExpressRouteCircuit = var.gr_remote_expr_id
9+
}
10+
})
11+
}

terraform/modules/avs_expressroute_globalreach/outputs.tf

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
terraform {
2+
required_providers {
3+
azapi = {
4+
source = "azure/azapi"
5+
}
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
variable "gr_connection_name" {
2+
type = string
3+
description = "Name for the new global reach connection"
4+
}
5+
6+
variable "private_cloud_id" {
7+
type = string
8+
description = "The Azure Resource ID for the private cloud where the global reach connection will originate from"
9+
}
10+
11+
variable "gr_remote_auth_key" {
12+
type = string
13+
description = "The authorization key value for the remote expressRoute where the global reach connection will connect to"
14+
}
15+
16+
variable "gr_remote_expr_id" {
17+
type = string
18+
description = "The Azure Resource ID for the remote expressRoute circuit where the global reach connection will connect to"
19+
}

0 commit comments

Comments
 (0)