terraform/modules/avs_expressroute_gateway/main.tf (54 lines of code) (raw):

resource "azurerm_public_ip" "gatewaypip" { name = var.expressroute_pip_name resource_group_name = var.rg_name location = var.rg_location allocation_method = "Static" sku = "Standard" tags = var.tags zones = ["1","2","3"] } resource "azurerm_virtual_network_gateway" "gateway" { name = var.expressroute_gateway_name resource_group_name = var.rg_name location = var.rg_location tags = var.tags type = "ExpressRoute" sku = var.expressroute_gateway_sku ip_configuration { name = "default" public_ip_address_id = azurerm_public_ip.gatewaypip.id private_ip_address_allocation = "Dynamic" subnet_id = var.gateway_subnet_id } } ############################################################################################# # Telemetry Section - Toggled on and off with the telemetry variable # This allows us to get deployment frequency statistics for deployments # Re-using parts of the Core Enterprise Landing Zone methodology ############################################################################################# locals { #create an empty ARM template to use for generating the deployment value telem_arm_subscription_template_content = <<TEMPLATE { "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "variables": {}, "resources": [], "outputs": { "telemetry": { "type": "String", "value": "For more information, see https://aka.ms/alz/tf/telemetry" } } } TEMPLATE module_identifier = lower("avs_expressroute_gateway") telem_arm_deployment_name = "${lower(var.guid_telemetry)}.${substr(local.module_identifier, 0, 20)}.${random_string.telemetry.result}" } #create a random string for uniqueness resource "random_string" "telemetry" { length = 4 special = false upper = false lower = true } resource "azurerm_subscription_template_deployment" "telemetry_core" { count = var.module_telemetry_enabled ? 1 : 0 name = local.telem_arm_deployment_name location = var.rg_location template_content = local.telem_arm_subscription_template_content }