Azure / Azure/Azure-Landing-Zones
Expose virtual_networks Output (including Subnet Details) from Hub Module
- Dominant language
- PowerShell
- Stars
- 96
- Forks
- 70
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 7
Description
### Check for previous/existing GitHub issues
- [x] I have checked for previous/existing GitHub issues
### Issue Type?
Feature Request
### (Optional) Module Version
0.5.1
### (Optional) Correlation Id
_No response_
### Description
**The Problem:**
This module (`Azure/avm-ptn-alz-connectivity-hub-and-spoke-vnet` v0.5.1) doesn't directly output crucial details like hub virtual network configurations and their subnet IDs. This information is often needed to integrate with other resources (e.g., NSGs, Private Endpoints, NVA NICs).
The module internally uses `module "hub_and_spoke_vnet"` (source: `Azure/avm-ptn-hubnetworking/azurerm`), which already makes this information available via its own `virtual_networks` output.
---
**Proposed Solution:**
1. **Primary Request: Expose the `virtual_networks` Output**
The most straightforward solution is to have this parent module output the comprehensive `virtual_networks` object from the underlying `module.hub_and_spoke_vnet`. This object contains VNet details, address spaces, and importantly, nested subnet information (including IDs).
Example for the parent module's `outputs.tf`:
```terraform
output "hub_virtual_networks_details" {
description = "Comprehensive details of the hub virtual networks, including subnets, sourced from the underlying hub networking module."
value = module.hub_and_spoke_vnet.virtual_networks
}
```
*(Using `hub_virtual_networks_details` as the output name to distinguish from `var.hub_virtual_networks` and be descriptive).*
2. **Optional Enhancement: Simplified `hub_subnets` Output for Convenience**
While the `virtual_networks` output (requested above) contains all subnet information, it is nested. For ease of use in scenarios where only a direct map of subnet details is needed, consider also providing a curated `hub_subnets` output. This would likely involve iterating through the `module.hub_and_spoke_vnet.virtual_networks` data within this parent module to construct a simpler map.
For example (conceptual, actual implementation would depend on desired structure):
```terraform
// This output would be constructed by this module:
output "hub_subnets_curated" {
description = "A curated map of hub subnet details for easier consumption."
value = { for vnet_key, vnet_data in module.hub_and_spoke_vnet.virtual_networks : vnet_key => vnet_data.subnets }
// Or a flatter structure if preferred, e.g., mapping subnet names/keys directly to their IDs.
}
```
---
**What I've Tried/Considered:**
* Forking the module to add the outputs manually (prefer to use the official module).
* Using Terraform `data` sources (less clean than the module outputting details of resources it creates/manages).
---
**Why this would be helpful:**
Direct access to hub VNet and subnet details (especially IDs and address prefixes) is essential for:
* Associating Network Security Groups (NSGs).
* Deploying Private Endpoints into specific hub subnets.
* Configuring Network Virtual Appliance (NVA) interfaces.
* Peering configurations and route table associations.
* General referencing from other Terraform configurations.
Contributor guide
Research direction
Start in outputs.tf and inspect module.hub_and_spoke_vnet.virtual_networks from the Azure/avm-ptn-hubnetworking/azurerm dependency. Done means the parent module exposes the VNet details, including nested subnet IDs and address prefixes, for downstream Terraform configurations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, terraform
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100