From ddf5da67c27fd8b556d6a10a2b74dd96779d16df Mon Sep 17 00:00:00 2001 From: "pablo.sanchez" Date: Thu, 5 Feb 2026 15:59:53 +0100 Subject: [PATCH 1/3] docs(azure-vnet-and-subnet): update docs and added examples --- .../azure-vnet-and-subnet/.terraform-docs.yml | 48 ++++++ modules/azure-vnet-and-subnet/README.md | 162 ++++++++++++++++++ .../_examples/basic/main.tf | 25 +++ .../_examples/basic/values.yaml | 19 ++ modules/azure-vnet-and-subnet/docs/footer.md | 12 ++ modules/azure-vnet-and-subnet/docs/header.md | 99 +++++++++++ 6 files changed, 365 insertions(+) create mode 100644 modules/azure-vnet-and-subnet/.terraform-docs.yml create mode 100644 modules/azure-vnet-and-subnet/_examples/basic/main.tf create mode 100644 modules/azure-vnet-and-subnet/_examples/basic/values.yaml create mode 100644 modules/azure-vnet-and-subnet/docs/footer.md create mode 100644 modules/azure-vnet-and-subnet/docs/header.md diff --git a/modules/azure-vnet-and-subnet/.terraform-docs.yml b/modules/azure-vnet-and-subnet/.terraform-docs.yml new file mode 100644 index 000000000..3a69365ff --- /dev/null +++ b/modules/azure-vnet-and-subnet/.terraform-docs.yml @@ -0,0 +1,48 @@ +formatter: "markdown" + +version: "" + +header-from: docs/header.md +footer-from: docs/footer.md + +recursive: + enabled: false + path: modules + include-main: true + +sections: + hide: [] + show: [] + +content: "" + +output: + file: "README.md" + mode: inject + template: |- + + {{ .Content }} + + +output-values: + enabled: false + from: "" + +sort: + enabled: true + by: name + +settings: + anchor: true + color: true + default: true + description: false + escape: true + hide-empty: false + html: true + indent: 2 + lockfile: true + read-comments: true + required: true + sensitive: true + type: true diff --git a/modules/azure-vnet-and-subnet/README.md b/modules/azure-vnet-and-subnet/README.md index ee1b074b3..c61ac54ec 100644 --- a/modules/azure-vnet-and-subnet/README.md +++ b/modules/azure-vnet-and-subnet/README.md @@ -150,3 +150,165 @@ vnet_peering_ids = { "myPeeringName" = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myVnetName/virtualNetworkPeerings/myPeeringName" } ``` + + +## Azure Virtual Network and Subnet Module + +This Terraform module creates and manages a Virtual Network (VNet) and subnets in Azure, including private DNS zones, peerings, and tagging. It is designed for deploying complex and reusable network infrastructures in Azure environments. + +### Features +- Create a VNet with multiple subnets +- Support for private DNS zones and virtual network links +- Configure network peerings +- Flexible tagging and tag inheritance from the resource group + +#### Example + +### Set a module + +```terraform +module "githuib-oidc" { + source = "git::https://github.com/prefapp/tfm.git//modules/azure-vnet-subnet?ref=" +} +``` + +```hcl +resource_group_name = "myResourceGroupName" + +virtual_network = { + name = "myVnetName" + location = "myLocation" + address_space = ["10.107.0.0/32"] + subnets = { + subnet1 = { + address_prefixes = ["10.107.0.0/18"] + service_endpoints = ["Microsoft.Storage"] + } + subnet2 = { + address_prefixes = ["10.107.64.0/24"] + service_endpoints = ["Microsoft.Storage"] + delegation = [ + { + name = "Microsoft.DBforPostgreSQL.flexibleServers" + service_delegation = { + name = "Microsoft.DBforPostgreSQL/flexibleServers" + actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"] + } + } + ] + } + } +} + +private_dns_zones = [ + { + name = "foo.councilbox.postgres.database.azure.com", + auto_registration_enabled = true + }, + { + name = "privatelink.redis.cache.windows.net" + link_name = "redis_link" + } +] + +peerings = [ + { + peering_name = "myPeeringName" + resource_group_name = "myResourceGroupName" + vnet_name = "myVnetName" + remote_virtual_network_id = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myRemoteVnetName" + } +] + +tags_from_rg = false +tags = { + environment = "myEnvironment" + department = "myDepartment" +} +``` + +## Output + +```hcl +private_dns_zone_ids = [ + "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/privatelink.redis.cache.windows.net", + "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/foo.councilbox.postgres.database.azure.com", +] + +private_dns_zone_virtual_network_link_ids = [ + "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/privatelink.redis.cache.windows.net/virtualNetworkLinks/bar-foo", + "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/foo.bar.postgres.database.azure.com/virtualNetworkLinks/foo-bar", +] + +subnet_ids = { + "myVnetName.subnet1" = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myVnetName/subnets/subnet1" + "myVnetName.subnet2" = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myVnetName/subnets/subnet2" +} + +vnet_id = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myVnetName" +vnet_peering_ids = { + "myPeeringName" = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myVnetName/virtualNetworkPeerings/myPeeringName" +} +``` + +## Requirements + +| Name | Version | +|------|---------| +| [azurerm](#requirement\_azurerm) | >=4.21.1 | + +## Providers + +| Name | Version | +|------|---------| +| [azurerm](#provider\_azurerm) | >=4.21.1 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [azurerm_private_dns_zone.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_dns_zone) | resource | +| [azurerm_private_dns_zone_virtual_network_link.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_dns_zone_virtual_network_link) | resource | +| [azurerm_subnet.subnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet) | resource | +| [azurerm_virtual_network.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network) | resource | +| [azurerm_virtual_network_peering.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network_peering) | resource | +| [azurerm_resource_group.resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) | data source | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [peerings](#input\_peerings) | List of virtual network peerings |
list(object({
peering_name = string
allow_forwarded_traffic = optional(bool, false)
allow_gateway_transit = optional(bool, false)
allow_virtual_network_access = optional(bool, true)
use_remote_gateways = optional(bool, false)
resource_group_name = string
vnet_name = string
remote_virtual_network_id = string
}))
| `[]` | no | +| [private\_dns\_zones](#input\_private\_dns\_zones) | List of private DNS zones to create |
list(object({
name = string
link_name = optional(string)
auto_registration_enabled = optional(bool, false)
}))
| `[]` | no | +| [resource\_group\_name](#input\_resource\_group\_name) | The name of the resource group in which to create the virtual network | `string` | n/a | yes | +| [tags](#input\_tags) | The tags to associate with your resources | `map(string)` | `{}` | no | +| [tags\_from\_rg](#input\_tags\_from\_rg) | Use the tags from the resource group | `bool` | `true` | no | +| [virtual\_network](#input\_virtual\_network) | Properties of the virtual network |
object({
name = string
location = string
address_space = list(string)
subnets = map(object({
address_prefixes = list(string)
private_endpoint_network_policies_enabled = optional(string, "Enabled")
private_link_service_network_policies_enabled = optional(bool, true)
service_endpoints = optional(list(string))
delegation = optional(list(object({
name = string
service_delegation = object({
name = string
actions = list(string)
})
})))
}))
})
| n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| [private\_dns\_zone\_ids](#output\_private\_dns\_zone\_ids) | Output the IDs of the private DNS zones | +| [private\_dns\_zone\_virtual\_network\_link\_ids](#output\_private\_dns\_zone\_virtual\_network\_link\_ids) | Output the IDs of the private DNS zone virtual network links | +| [subnet\_ids](#output\_subnet\_ids) | Output the IDs of the subnets with their names as keys | +| [vnet\_id](#output\_vnet\_id) | Output the ID of the virtual network | +| [vnet\_peering\_ids](#output\_vnet\_peering\_ids) | Output the IDs of the virtual network peerings with their names as keys | + +## Examples + +For detailed examples, refer to the [module examples](https://github.com/prefapp/tfm/tree/main/modules/azure-vnet-and-subnet/_examples): + +- [basic](https://github.com/prefapp/tfm/tree/main/modules/azure-vnet-and-subnet/_examples/basic) - Virtual network with one internal subnet. + +## Resources +- [Official Azure Virtual Network documentation](https://docs.microsoft.com/en-us/azure/virtual-network/virtual-networks-overview) +- [Terraform AzureRM Provider](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network) + +## Support +For issues, questions, or contributions related to this module, please visit the [repository's issue tracker](https://github.com/prefapp/tfm/issues). + \ No newline at end of file diff --git a/modules/azure-vnet-and-subnet/_examples/basic/main.tf b/modules/azure-vnet-and-subnet/_examples/basic/main.tf new file mode 100644 index 000000000..63095b2e8 --- /dev/null +++ b/modules/azure-vnet-and-subnet/_examples/basic/main.tf @@ -0,0 +1,25 @@ +// Basic example: Virtual Network with one subnet using azure-vnet-and-subnet module + +module "azure_vnet_and_subnet" { + source = "../../" + + resource_group_name = "example-rg" + + virtual_network = { + name = "example-vnet" + location = "westeurope" + address_space = ["10.0.0.0/16"] + subnets = { + internal = { + address_prefixes = ["10.0.1.0/24"] + } + } + } + + private_dns_zones = [] + peerings = [] + + tags = { + environment = "dev" + } +} \ No newline at end of file diff --git a/modules/azure-vnet-and-subnet/_examples/basic/values.yaml b/modules/azure-vnet-and-subnet/_examples/basic/values.yaml new file mode 100644 index 000000000..99597f571 --- /dev/null +++ b/modules/azure-vnet-and-subnet/_examples/basic/values.yaml @@ -0,0 +1,19 @@ +# Basic example values for azure-vnet-and-subnet module + +resource_group_name: example-rg + +virtual_network: + name: example-vnet + location: westeurope + address_space: + - 10.0.0.0/16 + subnets: + internal: + address_prefixes: + - 10.0.1.0/24 + +private_dns_zones: [] +peerings: [] + +tags: + environment: dev \ No newline at end of file diff --git a/modules/azure-vnet-and-subnet/docs/footer.md b/modules/azure-vnet-and-subnet/docs/footer.md new file mode 100644 index 000000000..dcb223926 --- /dev/null +++ b/modules/azure-vnet-and-subnet/docs/footer.md @@ -0,0 +1,12 @@ +## Examples + +For detailed examples, refer to the [module examples](https://github.com/prefapp/tfm/tree/main/modules/azure-vnet-and-subnet/_examples): + +- [basic](https://github.com/prefapp/tfm/tree/main/modules/azure-vnet-and-subnet/_examples/basic) - Virtual network with one internal subnet. + +## Resources +- [Official Azure Virtual Network documentation](https://docs.microsoft.com/en-us/azure/virtual-network/virtual-networks-overview) +- [Terraform AzureRM Provider](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network) + +## Support +For issues, questions, or contributions related to this module, please visit the [repository's issue tracker](https://github.com/prefapp/tfm/issues). \ No newline at end of file diff --git a/modules/azure-vnet-and-subnet/docs/header.md b/modules/azure-vnet-and-subnet/docs/header.md new file mode 100644 index 000000000..fc78a21a2 --- /dev/null +++ b/modules/azure-vnet-and-subnet/docs/header.md @@ -0,0 +1,99 @@ +## Azure Virtual Network and Subnet Module + +This Terraform module creates and manages a Virtual Network (VNet) and subnets in Azure, including private DNS zones, peerings, and tagging. It is designed for deploying complex and reusable network infrastructures in Azure environments. + +### Features +- Create a VNet with multiple subnets +- Support for private DNS zones and virtual network links +- Configure network peerings +- Flexible tagging and tag inheritance from the resource group + + +#### Example + +### Set a module + +```terraform +module "githuib-oidc" { + source = "git::https://github.com/prefapp/tfm.git//modules/azure-vnet-subnet?ref=" +} +``` + +```hcl +resource_group_name = "myResourceGroupName" + +virtual_network = { + name = "myVnetName" + location = "myLocation" + address_space = ["10.107.0.0/32"] + subnets = { + subnet1 = { + address_prefixes = ["10.107.0.0/18"] + service_endpoints = ["Microsoft.Storage"] + } + subnet2 = { + address_prefixes = ["10.107.64.0/24"] + service_endpoints = ["Microsoft.Storage"] + delegation = [ + { + name = "Microsoft.DBforPostgreSQL.flexibleServers" + service_delegation = { + name = "Microsoft.DBforPostgreSQL/flexibleServers" + actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"] + } + } + ] + } + } +} + +private_dns_zones = [ + { + name = "foo.councilbox.postgres.database.azure.com", + auto_registration_enabled = true + }, + { + name = "privatelink.redis.cache.windows.net" + link_name = "redis_link" + } +] + +peerings = [ + { + peering_name = "myPeeringName" + resource_group_name = "myResourceGroupName" + vnet_name = "myVnetName" + remote_virtual_network_id = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myRemoteVnetName" + } +] + +tags_from_rg = false +tags = { + environment = "myEnvironment" + department = "myDepartment" +} +``` + +## Output + +```hcl +private_dns_zone_ids = [ + "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/privatelink.redis.cache.windows.net", + "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/foo.councilbox.postgres.database.azure.com", +] + +private_dns_zone_virtual_network_link_ids = [ + "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/privatelink.redis.cache.windows.net/virtualNetworkLinks/bar-foo", + "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/foo.bar.postgres.database.azure.com/virtualNetworkLinks/foo-bar", +] + +subnet_ids = { + "myVnetName.subnet1" = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myVnetName/subnets/subnet1" + "myVnetName.subnet2" = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myVnetName/subnets/subnet2" +} + +vnet_id = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myVnetName" +vnet_peering_ids = { + "myPeeringName" = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myVnetName/virtualNetworkPeerings/myPeeringName" +} +``` \ No newline at end of file From 3a570850b3b7f647f97d6ced283e5b2e626876ed Mon Sep 17 00:00:00 2001 From: "pablo.sanchez" Date: Tue, 10 Feb 2026 10:12:24 +0100 Subject: [PATCH 2/3] Update Readme --- modules/azure-vnet-and-subnet/README.md | 153 ------------------------ 1 file changed, 153 deletions(-) diff --git a/modules/azure-vnet-and-subnet/README.md b/modules/azure-vnet-and-subnet/README.md index c61ac54ec..defa21792 100644 --- a/modules/azure-vnet-and-subnet/README.md +++ b/modules/azure-vnet-and-subnet/README.md @@ -1,156 +1,3 @@ -# Azure virtual network(s) and subnet(s) - -## Overview - -This module creates one or more virtual networks and subnets. - -## DOC - -- [Resource terraform - azurerm_virtual_network](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network) -- [Resource terraform - azurerm_subnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet) -- [Resource terraform - azurerm_virtual_network_peering](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network_peering) -- [Resource terraform - azurerm_private_dns_zone](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_dns_zone) -- [Resource terraform - azurerm_private_dns_zone_virtual_network_link](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_dns_zone_virtual_network_link) - -## Usage - -## Observations - -Al resources are created in the same resource group. - -### Set a module - -```terraform -module "githuib-oidc" { - source = "git::https://github.com/prefapp/tfm.git//modules/azure-vnet-subnet?ref=" -} -``` - -#### Example - -```terraform -module "githuib-oidc" { - source = "git::https://github.com/prefapp/tfm.git//modules/azure-vnet-subnet?ref=v1.2.3" -} -``` - -## Inputs -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| `virtual_network` | Properties of the virtual network | object | n/a | yes | -| `virtual_network.name` | The name of the virtual network | string | n/a | yes | -| `virtual_network.location` | The location of the virtual network | string | n/a | yes | -| `virtual_network.address_space` | The address space of the virtual network | list(string) | n/a | yes | -| `virtual_network.subnets` | Map of subnets within the virtual network | map(object) | n/a | yes | -| `virtual_network.subnets.address_prefixes` | List of address prefixes for the subnet | list(string) | n/a | yes | -| `virtual_network.subnets.private_endpoint_network_policies_enabled` | Whether private endpoint network policies are enabled | string | `Enabled` | no | -| `virtual_network.subnets.private_link_service_network_policies_enabled` | Whether private link service network policies are enabled | bool | `true` | no | -| `virtual_network.subnets.service_endpoints` | List of service endpoints for the subnet | list(string) | `[]` | no | -| `virtual_network.subnets.delegation` | List of delegations for the subnet | list(object) | `[]` | no | -| `virtual_network.subnets.delegation.name` | The name of the delegation | string | n/a | yes | -| `virtual_network.subnets.delegation.service_delegation` | Service delegation details | object | n/a | yes | -| `virtual_network.subnets.delegation.service_delegation.name` | The name of the service delegation | string | n/a | yes | -| `virtual_network.subnets.delegation.service_delegation.actions` | List of actions for the service delegation | list(string) | n/a | yes | -| `private_dns_zones` | List of private DNS zones to create | list(object) | `[]` | no | -| `private_dns_zones.name` | The name of the private DNS zone | string | n/a | yes | -| `private_dns_zones.link_name` | The name of the private DNS zone VNET link | string | n/a | no | -| `private_dns_zones.auto_registration_enabled` | Whether auto registration is enabled | bool | `false` | no | -| `peerings` | List of virtual network peerings | list(object) | `[]` | no | -| `peerings.peering_name` | The name of the peering | string | n/a | yes | -| `peerings.allow_forwarded_traffic` | Whether forwarded traffic is allowed | bool | `false` | no | -| `peerings.allow_gateway_transit` | Whether gateway transit is allowed | bool | `false` | no | -| `peerings.allow_virtual_network_access` | Whether virtual network access is allowed | bool | `true` | no | -| `peerings.use_remote_gateways` | Whether to use remote gateways | bool | `false` | no | -| `peerings.resource_group_name` | The name of the resource group for the peering | string | n/a | yes | -| `peerings.vnet_name` | The name of the virtual network for the peering | string | n/a | yes | -| `peerings.remote_virtual_network_id` | The ID of the remote virtual network | string | n/a | yes | -| `resource_group_name` | The name of the resource group in which to create the virtual network | string | n/a | yes | -| `tags` | A map of tags to add to the public IP | map(string) | `{}` | no | -| `tags_from_rg` | Use the tags from the resource group, if true, the tags set in the tags variable will be ignored | bool | `true` | no | - -### Set a data .tfvars - -#### Example - -```hcl -resource_group_name = "myResourceGroupName" - -virtual_network = { - name = "myVnetName" - location = "myLocation" - address_space = ["10.107.0.0/32"] - subnets = { - subnet1 = { - address_prefixes = ["10.107.0.0/18"] - service_endpoints = ["Microsoft.Storage"] - } - subnet2 = { - address_prefixes = ["10.107.64.0/24"] - service_endpoints = ["Microsoft.Storage"] - delegation = [ - { - name = "Microsoft.DBforPostgreSQL.flexibleServers" - service_delegation = { - name = "Microsoft.DBforPostgreSQL/flexibleServers" - actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"] - } - } - ] - } - } -} - -private_dns_zones = [ - { - name = "foo.councilbox.postgres.database.azure.com", - auto_registration_enabled = true - }, - { - name = "privatelink.redis.cache.windows.net" - link_name = "redis_link" - } -] - -peerings = [ - { - peering_name = "myPeeringName" - resource_group_name = "myResourceGroupName" - vnet_name = "myVnetName" - remote_virtual_network_id = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myRemoteVnetName" - } -] - -tags_from_rg = false -tags = { - environment = "myEnvironment" - department = "myDepartment" -} -``` - -## Output - -```hcl -private_dns_zone_ids = [ - "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/privatelink.redis.cache.windows.net", - "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/foo.councilbox.postgres.database.azure.com", -] - -private_dns_zone_virtual_network_link_ids = [ - "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/privatelink.redis.cache.windows.net/virtualNetworkLinks/bar-foo", - "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/foo.bar.postgres.database.azure.com/virtualNetworkLinks/foo-bar", -] - -subnet_ids = { - "myVnetName.subnet1" = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myVnetName/subnets/subnet1" - "myVnetName.subnet2" = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myVnetName/subnets/subnet2" -} - -vnet_id = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myVnetName" -vnet_peering_ids = { - "myPeeringName" = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myVnetName/virtualNetworkPeerings/myPeeringName" -} -``` - ## Azure Virtual Network and Subnet Module From 2fa93ef5372754f7fc350a01becd28c8aa3fbb84 Mon Sep 17 00:00:00 2001 From: "pablo.sanchez" Date: Tue, 10 Feb 2026 11:04:32 +0100 Subject: [PATCH 3/3] docs(azure): update Readme --- modules/azure-vnet-and-subnet/README.md | 128 +++++++++++-------- modules/azure-vnet-and-subnet/docs/header.md | 128 +++++++++++-------- 2 files changed, 152 insertions(+), 104 deletions(-) diff --git a/modules/azure-vnet-and-subnet/README.md b/modules/azure-vnet-and-subnet/README.md index defa21792..2fd6ef38b 100644 --- a/modules/azure-vnet-and-subnet/README.md +++ b/modules/azure-vnet-and-subnet/README.md @@ -9,68 +9,92 @@ This Terraform module creates and manages a Virtual Network (VNet) and subnets i - Configure network peerings - Flexible tagging and tag inheritance from the resource group -#### Example +### Basic example -### Set a module +```hcl +module "azure_vnet_and_subnet" { + source = "git::https://github.com/prefapp/tfm.git//modules/azure-vnet-and-subnet?ref=" + + resource_group_name = "example-rg" + + virtual_network = { + name = "example-vnet" + location = "westeurope" + address_space = ["10.0.0.0/16"] + subnets = { + internal = { + address_prefixes = ["10.0.1.0/24"] + } + } + } + + private_dns_zones = [] + peerings = [] -```terraform -module "githuib-oidc" { - source = "git::https://github.com/prefapp/tfm.git//modules/azure-vnet-subnet?ref=" + tags = { + environment = "dev" + } } ``` +### Advanced example + ```hcl -resource_group_name = "myResourceGroupName" - -virtual_network = { - name = "myVnetName" - location = "myLocation" - address_space = ["10.107.0.0/32"] - subnets = { - subnet1 = { - address_prefixes = ["10.107.0.0/18"] - service_endpoints = ["Microsoft.Storage"] - } - subnet2 = { - address_prefixes = ["10.107.64.0/24"] - service_endpoints = ["Microsoft.Storage"] - delegation = [ - { - name = "Microsoft.DBforPostgreSQL.flexibleServers" - service_delegation = { - name = "Microsoft.DBforPostgreSQL/flexibleServers" - actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"] +module "azure_vnet_and_subnet" { + source = "git::https://github.com/prefapp/tfm.git//modules/azure-vnet-and-subnet?ref=" + + resource_group_name = "myResourceGroupName" + + virtual_network = { + name = "myVnetName" + location = "myLocation" + address_space = ["10.107.0.0/16"] + subnets = { + subnet1 = { + address_prefixes = ["10.107.0.0/18"] + service_endpoints = ["Microsoft.Storage"] + } + subnet2 = { + address_prefixes = ["10.107.64.0/24"] + service_endpoints = ["Microsoft.Storage"] + delegation = [ + { + name = "Microsoft.DBforPostgreSQL.flexibleServers" + service_delegation = { + name = "Microsoft.DBforPostgreSQL/flexibleServers" + actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"] + } } - } - ] + ] + } } } -} -private_dns_zones = [ - { - name = "foo.councilbox.postgres.database.azure.com", - auto_registration_enabled = true - }, - { - name = "privatelink.redis.cache.windows.net" - link_name = "redis_link" - } -] + private_dns_zones = [ + { + name = "foo.councilbox.postgres.database.azure.com" + auto_registration_enabled = true + }, + { + name = "privatelink.redis.cache.windows.net" + link_name = "redis_link" + } + ] + + peerings = [ + { + peering_name = "myPeeringName" + resource_group_name = "myResourceGroupName" + vnet_name = "myVnetName" + remote_virtual_network_id = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myRemoteVnetName" + } + ] -peerings = [ - { - peering_name = "myPeeringName" - resource_group_name = "myResourceGroupName" - vnet_name = "myVnetName" - remote_virtual_network_id = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myRemoteVnetName" + tags_from_rg = false + tags = { + environment = "myEnvironment" + department = "myDepartment" } -] - -tags_from_rg = false -tags = { - environment = "myEnvironment" - department = "myDepartment" } ``` @@ -83,8 +107,8 @@ private_dns_zone_ids = [ ] private_dns_zone_virtual_network_link_ids = [ - "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/privatelink.redis.cache.windows.net/virtualNetworkLinks/bar-foo", - "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/foo.bar.postgres.database.azure.com/virtualNetworkLinks/foo-bar", + "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/privatelink.redis.cache.windows.net/virtualNetworkLinks/redis_link", + "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/foo.councilbox.postgres.database.azure.com/virtualNetworkLinks/redis_link", ] subnet_ids = { diff --git a/modules/azure-vnet-and-subnet/docs/header.md b/modules/azure-vnet-and-subnet/docs/header.md index fc78a21a2..206c22719 100644 --- a/modules/azure-vnet-and-subnet/docs/header.md +++ b/modules/azure-vnet-and-subnet/docs/header.md @@ -9,68 +9,92 @@ This Terraform module creates and manages a Virtual Network (VNet) and subnets i - Flexible tagging and tag inheritance from the resource group -#### Example +### Basic example -### Set a module +```hcl +module "azure_vnet_and_subnet" { + source = "git::https://github.com/prefapp/tfm.git//modules/azure-vnet-and-subnet?ref=" + + resource_group_name = "example-rg" + + virtual_network = { + name = "example-vnet" + location = "westeurope" + address_space = ["10.0.0.0/16"] + subnets = { + internal = { + address_prefixes = ["10.0.1.0/24"] + } + } + } + + private_dns_zones = [] + peerings = [] -```terraform -module "githuib-oidc" { - source = "git::https://github.com/prefapp/tfm.git//modules/azure-vnet-subnet?ref=" + tags = { + environment = "dev" + } } ``` +### Advanced example + ```hcl -resource_group_name = "myResourceGroupName" - -virtual_network = { - name = "myVnetName" - location = "myLocation" - address_space = ["10.107.0.0/32"] - subnets = { - subnet1 = { - address_prefixes = ["10.107.0.0/18"] - service_endpoints = ["Microsoft.Storage"] - } - subnet2 = { - address_prefixes = ["10.107.64.0/24"] - service_endpoints = ["Microsoft.Storage"] - delegation = [ - { - name = "Microsoft.DBforPostgreSQL.flexibleServers" - service_delegation = { - name = "Microsoft.DBforPostgreSQL/flexibleServers" - actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"] +module "azure_vnet_and_subnet" { + source = "git::https://github.com/prefapp/tfm.git//modules/azure-vnet-and-subnet?ref=" + + resource_group_name = "myResourceGroupName" + + virtual_network = { + name = "myVnetName" + location = "myLocation" + address_space = ["10.107.0.0/16"] + subnets = { + subnet1 = { + address_prefixes = ["10.107.0.0/18"] + service_endpoints = ["Microsoft.Storage"] + } + subnet2 = { + address_prefixes = ["10.107.64.0/24"] + service_endpoints = ["Microsoft.Storage"] + delegation = [ + { + name = "Microsoft.DBforPostgreSQL.flexibleServers" + service_delegation = { + name = "Microsoft.DBforPostgreSQL/flexibleServers" + actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"] + } } - } - ] + ] + } } } -} -private_dns_zones = [ - { - name = "foo.councilbox.postgres.database.azure.com", - auto_registration_enabled = true - }, - { - name = "privatelink.redis.cache.windows.net" - link_name = "redis_link" - } -] + private_dns_zones = [ + { + name = "foo.councilbox.postgres.database.azure.com" + auto_registration_enabled = true + }, + { + name = "privatelink.redis.cache.windows.net" + link_name = "redis_link" + } + ] + + peerings = [ + { + peering_name = "myPeeringName" + resource_group_name = "myResourceGroupName" + vnet_name = "myVnetName" + remote_virtual_network_id = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myRemoteVnetName" + } + ] -peerings = [ - { - peering_name = "myPeeringName" - resource_group_name = "myResourceGroupName" - vnet_name = "myVnetName" - remote_virtual_network_id = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/virtualNetworks/myRemoteVnetName" + tags_from_rg = false + tags = { + environment = "myEnvironment" + department = "myDepartment" } -] - -tags_from_rg = false -tags = { - environment = "myEnvironment" - department = "myDepartment" } ``` @@ -83,8 +107,8 @@ private_dns_zone_ids = [ ] private_dns_zone_virtual_network_link_ids = [ - "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/privatelink.redis.cache.windows.net/virtualNetworkLinks/bar-foo", - "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/foo.bar.postgres.database.azure.com/virtualNetworkLinks/foo-bar", + "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/privatelink.redis.cache.windows.net/virtualNetworkLinks/redis_link", + "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Network/privateDnsZones/foo.councilbox.postgres.database.azure.com/virtualNetworkLinks/redis_link", ] subnet_ids = {