Closed kewalaka closed 7 months ago
Just to add more weight to this suggestion, the current code in this module is based on a resource that has been deprecated (terraform-azurerm-vnet), according to the notice inside the readme:
For the new infrastructure, you should use this module (https://github.com/Azure/terraform-azurerm-subnets) instead of terraform-azurerm-vnet. For existing infrastructure, we'll maintain terraform-azurerm-vnet module, fix bugs and amend new features.
Hi @kewalaka,
Thanks for the feedback. You are right, the subnet should be converted into an object to support all of those dependencies. I'm working on improving this and is scheduled for the next update.
Feel free to submit a PR as well @kewalaka if you have it already :)
Thanks!
@herms14 no worries glad to contribute help 🙂 I was just checking before I created something, but what I was going to propose was to swap out the main body of the code for the content here - https://github.com/Azure/terraform-azurerm-subnets
There will be some features we may need to fold back in, but I think that's a better starting point. I'll raise a PR to illustrate, hopefully in the next couple days.
Hi @kewalaka , I already have the code ready and is pending review by the AVM core team. Will update once PR has been approved.
Fixed in PR #20
Currently, the code creates a list of subnets like this:
& associations are done like this (this example illustrates service delegations:
A more "terraform-like" way to do this is illustrated in this repository:
https://github.com/Azure/terraform-azurerm-subnets
An example from this project:
This is better as it allows you to specify the subnet hierarchy as a typed variable, instead of the current method which is more prone to error.
It also improves readability as the number of subnets grows, since the information relating to a subnet is in the same object definition.
@herms14 - would you support a PR to align to this approach?