From e7a5d2381c5be3c4655aeda4d385fc62e78c2093 Mon Sep 17 00:00:00 2001 From: Fraser Davidson Date: Mon, 8 Jan 2024 14:44:45 +0000 Subject: [PATCH] Add Virtual WAN module (#42) --- modules/virtual-wan/CHANGELOG.md | 1 + modules/virtual-wan/README.md | 29 +++++++++++++++++++++++++++ modules/virtual-wan/VERSION | 1 + modules/virtual-wan/src/locals.tf | 14 +++++++++++++ modules/virtual-wan/src/main.tf | 7 +++++++ modules/virtual-wan/src/outputs.tf | 7 +++++++ modules/virtual-wan/src/variables.tf | 24 ++++++++++++++++++++++ modules/virtual-wan/test/main.tf | 17 ++++++++++++++++ modules/virtual-wan/test/terraform.tf | 10 +++++++++ 9 files changed, 110 insertions(+) create mode 100644 modules/virtual-wan/CHANGELOG.md create mode 100644 modules/virtual-wan/README.md create mode 100644 modules/virtual-wan/VERSION create mode 100644 modules/virtual-wan/src/locals.tf create mode 100644 modules/virtual-wan/src/main.tf create mode 100644 modules/virtual-wan/src/outputs.tf create mode 100644 modules/virtual-wan/src/variables.tf create mode 100644 modules/virtual-wan/test/main.tf create mode 100644 modules/virtual-wan/test/terraform.tf diff --git a/modules/virtual-wan/CHANGELOG.md b/modules/virtual-wan/CHANGELOG.md new file mode 100644 index 0000000..825c32f --- /dev/null +++ b/modules/virtual-wan/CHANGELOG.md @@ -0,0 +1 @@ +# Changelog diff --git a/modules/virtual-wan/README.md b/modules/virtual-wan/README.md new file mode 100644 index 0000000..a2672ba --- /dev/null +++ b/modules/virtual-wan/README.md @@ -0,0 +1,29 @@ +# Virtual WAN + +This module creates a [Virtual WAN](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_wan). + +## Usage + +```hcl +module "virtual_wan" { + source = "https://github.com/gofrontier-com/azurerm-terraform-modules/releases/download/virtual-wan/[VERSION]/module.tar.gz//src" + + environment = "con" + identifier = "main" + location = "uksouth" + resource_group_name = module.resource_group.name + zone = "pla" + + tags = { + WorkloadType = "PlatformLZ/virtual-wan" + } +} +``` + +## Known issues + +_None._ + +## Contributing + +See . diff --git a/modules/virtual-wan/VERSION b/modules/virtual-wan/VERSION new file mode 100644 index 0000000..d3827e7 --- /dev/null +++ b/modules/virtual-wan/VERSION @@ -0,0 +1 @@ +1.0 diff --git a/modules/virtual-wan/src/locals.tf b/modules/virtual-wan/src/locals.tf new file mode 100644 index 0000000..6a78776 --- /dev/null +++ b/modules/virtual-wan/src/locals.tf @@ -0,0 +1,14 @@ +locals { + identifier = replace(lower(var.identifier), "/[^a-z1-9]/", "") + + short_locations = { + "uksouth" = "uks" + "ukwest" = "ukw" + } + + tags = { + Environment = var.environment + Location = var.location + Zone = var.zone + } +} diff --git a/modules/virtual-wan/src/main.tf b/modules/virtual-wan/src/main.tf new file mode 100644 index 0000000..325bcfe --- /dev/null +++ b/modules/virtual-wan/src/main.tf @@ -0,0 +1,7 @@ +resource "azurerm_virtual_wan" "main" { + name = "vwan-${var.zone}-${var.environment}-${lookup(local.short_locations, var.location)}-${local.identifier}" + resource_group_name = var.resource_group_name + location = var.location + + tags = merge(var.tags, local.tags) +} diff --git a/modules/virtual-wan/src/outputs.tf b/modules/virtual-wan/src/outputs.tf new file mode 100644 index 0000000..fd64f0a --- /dev/null +++ b/modules/virtual-wan/src/outputs.tf @@ -0,0 +1,7 @@ +output "id" { + value = azurerm_virtual_wan.main.id +} + +output "name" { + value = azurerm_virtual_wan.main.name +} diff --git a/modules/virtual-wan/src/variables.tf b/modules/virtual-wan/src/variables.tf new file mode 100644 index 0000000..cf3d14b --- /dev/null +++ b/modules/virtual-wan/src/variables.tf @@ -0,0 +1,24 @@ +variable "environment" { + type = string +} + +variable "identifier" { + type = string +} + +variable "location" { + type = string +} + +variable "resource_group_name" { + type = string +} + +variable "tags" { + type = map(string) + default = {} +} + +variable "zone" { + type = string +} diff --git a/modules/virtual-wan/test/main.tf b/modules/virtual-wan/test/main.tf new file mode 100644 index 0000000..4ca1aa8 --- /dev/null +++ b/modules/virtual-wan/test/main.tf @@ -0,0 +1,17 @@ +provider "azurerm" { + features {} +} + +module "virtual_wan" { + source = "../src" + + environment = "bar" + identifier = "baz" + location = "uksouth" + resource_group_name = "baz" + zone = "bat" + + tags = { + Foo = "Bar" + } +} diff --git a/modules/virtual-wan/test/terraform.tf b/modules/virtual-wan/test/terraform.tf new file mode 100644 index 0000000..762ef2e --- /dev/null +++ b/modules/virtual-wan/test/terraform.tf @@ -0,0 +1,10 @@ +terraform { + required_version = "~> 1.5" + + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "~> 3.85" + } + } +}