azurerm_virtual_network - support for ip_address_pool #29021
azurerm_virtual_network - support for ip_address_pool #29021catriona-m merged 7 commits intohashicorp:mainfrom
azurerm_virtual_network - support for ip_address_pool #29021Conversation
…m into vnet-ip-pool
catriona-m
left a comment
There was a problem hiding this comment.
Thanks @teowa - I've left some comments inline but once those are addressed we can take another look. Thanks!
| ValidateFunc: ipampools.ValidateIPamPoolID, | ||
| }, | ||
|
|
||
| "ip_address_number": { |
There was a problem hiding this comment.
could we change this to number_of_ip_addresses to make this more clear?
| }, | ||
|
|
||
| "ip_address_number": { | ||
| Type: pluginsdk.TypeString, |
There was a problem hiding this comment.
We need to keep this as a string, as number of IPv6 addresses can be up to 128-bit integers.
| if payload.Properties.AddressSpace == nil { | ||
| payload.Properties.AddressSpace = &virtualnetworks.AddressSpace{} | ||
| } | ||
| if v := d.Get("address_space").(*pluginsdk.Set).List(); len(v) > 0 { |
There was a problem hiding this comment.
| if payload.Properties.AddressSpace == nil { | |
| payload.Properties.AddressSpace = &virtualnetworks.AddressSpace{} | |
| } | |
| if v := d.Get("address_space").(*pluginsdk.Set).List(); len(v) > 0 { | |
| if v := d.Get("address_space").(*pluginsdk.Set).List(); len(v) > 0 { | |
| if payload.Properties.AddressSpace == nil { | |
| payload.Properties.AddressSpace = &virtualnetworks.AddressSpace{} | |
| } |
| if payload.Properties.AddressSpace == nil { | ||
| payload.Properties.AddressSpace = &virtualnetworks.AddressSpace{} | ||
| } |
There was a problem hiding this comment.
| if payload.Properties.AddressSpace == nil { | |
| payload.Properties.AddressSpace = &virtualnetworks.AddressSpace{} | |
| } |
| } | ||
|
|
||
| payload.Properties.AddressSpace.AddressPrefixes = utils.ExpandStringSlice(d.Get("address_space").(*pluginsdk.Set).List()) | ||
| if v := d.Get("ip_address_pool").([]interface{}); len(v) > 0 { |
There was a problem hiding this comment.
| if v := d.Get("ip_address_pool").([]interface{}); len(v) > 0 { | |
| if v := d.Get("ip_address_pool").([]interface{}); len(v) > 0 { | |
| if payload.Properties.AddressSpace == nil { | |
| payload.Properties.AddressSpace = &virtualnetworks.AddressSpace{} | |
| } |
|
|
||
| outputs := make([]interface{}, 0) | ||
| for _, v := range *input { | ||
| if v.Pool != nil && v.Pool.Id != nil { |
There was a problem hiding this comment.
we shouldn't need to check v.Pool.Id != nil here since pointer.From(v.Pool.Id), should handle this?
| "ip_address_number": pointer.From(v.NumberOfIPAddresses), | ||
| "allocated_ip_address_prefixes": pointer.From(v.AllocatedAddressPrefixes), |
There was a problem hiding this comment.
should we set these separately from id incase v.Pool is nil, but v.NumberOfIPAddresses and v.AllocatedAddressPrefixes are not?
| ), | ||
| }, | ||
| data.ImportStep(), | ||
| // The ip_address_number can only be increated, so here we don't update back |
There was a problem hiding this comment.
can we check for this case in the update and return an error if a user attempts to decrease the number of ip addresses?
|
|
||
| "location": commonschema.Location(), | ||
|
|
||
| // Optional |
|
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |

Community Note
Description
azurerm_virtual_network- support forip_address_poolAzure Documentation: https://learn.microsoft.com/azure/virtual-network-manager/how-to-manage-ip-addresses-network-manager?tabs=azureportal#associate-a-virtual-network-with-an-ip-address-pool
REST API: https://learn.microsoft.com/rest/api/virtualnetwork/virtual-networks/create-or-update?view=rest-virtualnetwork-2024-05-01&tabs=HTTP#ipampoolprefixallocation
PR Checklist
For example: “
resource_name_here- description of change e.g. adding propertynew_property_name_here”Changes to existing Resource / Data Source
Testing
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_virtual_network- support forip_address_poolThis is a (please select all that apply):
Related Issue(s)
Fixes #0000
Note
If this PR changes meaningfully during the course of review please update the title and description as required.