New Resource: azurerm_network_manager_ipam_pool_static_cidr#29501
New Resource: azurerm_network_manager_ipam_pool_static_cidr#29501wyattfry merged 9 commits intohashicorp:mainfrom
azurerm_network_manager_ipam_pool_static_cidr#29501Conversation
ms-zhenhua
left a comment
There was a problem hiding this comment.
Hi @teowa ,
Thanks for this PR - I've taken a look through and left some comments inline. If we can fix those up, this should be good to go 👍
| }, | ||
|
|
||
| "number_of_ip_addresses_to_allocate": { | ||
| Type: pluginsdk.TypeString, |
There was a problem hiding this comment.
why not directly define it as an int type?
There was a problem hiding this comment.
for IPv6 addresses, this field might be up to 128 bit integer, so we need to use string type for this.
| if metadata.ResourceData.HasChange("address_prefixes") { | ||
| if len(model.AddressPrefixes) > 0 { | ||
| parameters.Properties.AddressPrefixes = pointer.To(model.AddressPrefixes) | ||
| parameters.Properties.NumberOfIPAddressesToAllocate = pointer.To("") |
There was a problem hiding this comment.
why not set NumberOfIPAddressesToAllocate in else branch?
There was a problem hiding this comment.
Both address_prefixes and number_of_ip_addresses_to_allocate will be returned by API but only one of them can be set. When ignore_changes is applied to the unused field, it must be explicitly set to an empty value.
| if metadata.ResourceData.HasChange("number_of_ip_addresses_to_allocate") { | ||
| if model.NumberOfIPAddressesToAllocate != "" { | ||
| parameters.Properties.NumberOfIPAddressesToAllocate = pointer.To(model.NumberOfIPAddressesToAllocate) | ||
| parameters.Properties.AddressPrefixes = pointer.To([]string{}) |
|
|
||
| * `address_prefixes` - (Optional) Specifies a list of IPv4 or IPv6 IP address prefixes which will be allocated to the Static CIDR. | ||
|
|
||
| -> **NOTE:** Exactly one of `address_prefixes` or `number_of_ip_addresses_to_allocate` must be specified. If you set either property, the Azure API will automatically configure the other. Therefore, if you set `address_prefixes`, consider adding `number_of_ip_addresses_to_allocate` to `ignore_changes` to avoid plan diff. |
There was a problem hiding this comment.
| -> **NOTE:** Exactly one of `address_prefixes` or `number_of_ip_addresses_to_allocate` must be specified. If you set either property, the Azure API will automatically configure the other. Therefore, if you set `address_prefixes`, consider adding `number_of_ip_addresses_to_allocate` to `ignore_changes` to avoid plan diff. | |
| -> **Note:** Exactly one of `address_prefixes` or `number_of_ip_addresses_to_allocate` must be specified. If you set either property, the Azure API will automatically configure the other. Therefore, if you set `address_prefixes`, consider adding `number_of_ip_addresses_to_allocate` to `ignore_changes` to avoid plan diff. |
|
|
||
| * `number_of_ip_addresses_to_allocate` - (Optional) The number of IP addresses to allocated to the Static CIDR. The value must be a string that represents a positive number, e.g., `"16"`. | ||
|
|
||
| -> **NOTE:** Exactly one of `address_prefixes` or `number_of_ip_addresses_to_allocate` must be specified. If you set either property, the Azure API will automatically configure the other. Therefore, if you set `number_of_ip_addresses_to_allocate`, consider adding `address_prefixes` to `ignore_changes` to avoid plan diff. |
There was a problem hiding this comment.
| -> **NOTE:** Exactly one of `address_prefixes` or `number_of_ip_addresses_to_allocate` must be specified. If you set either property, the Azure API will automatically configure the other. Therefore, if you set `number_of_ip_addresses_to_allocate`, consider adding `address_prefixes` to `ignore_changes` to avoid plan diff. | |
| -> **Note:** Exactly one of `address_prefixes` or `number_of_ip_addresses_to_allocate` must be specified. If you set either property, the Azure API will automatically configure the other. Therefore, if you set `number_of_ip_addresses_to_allocate`, consider adding `address_prefixes` to `ignore_changes` to avoid plan diff. |
|
|
||
| -> **NOTE:** Exactly one of `address_prefixes` or `number_of_ip_addresses_to_allocate` must be specified. If you set either property, the Azure API will automatically configure the other. Therefore, if you set `number_of_ip_addresses_to_allocate`, consider adding `address_prefixes` to `ignore_changes` to avoid plan diff. | ||
|
|
||
| -> **NOTE:** If `number_of_ip_addresses_to_allocate` is not set to a power of 2, Azure API will return the nearest power of 2. For instance, if `number_of_ip_addresses_to_allocate` is `"20"`, Azure API will automatically update it to `"32"`. In such cases, please update the `number_of_ip_addresses_to_allocate` in the configuration file to this new value. |
There was a problem hiding this comment.
could you add a validation of a power of 2 in the provider so that the users will not miss configure the unacceptable value ?
| -> **NOTE:** If `number_of_ip_addresses_to_allocate` is not set to a power of 2, Azure API will return the nearest power of 2. For instance, if `number_of_ip_addresses_to_allocate` is `"20"`, Azure API will automatically update it to `"32"`. In such cases, please update the `number_of_ip_addresses_to_allocate` in the configuration file to this new value. | |
| -> **Note:** If `number_of_ip_addresses_to_allocate` is not set to a power of 2, Azure API will return the nearest power of 2. For instance, if `number_of_ip_addresses_to_allocate` is `"20"`, Azure API will automatically update it to `"32"`. In such cases, please update the `number_of_ip_addresses_to_allocate` in the configuration file to this new value. |
There was a problem hiding this comment.
updated, a validation is added
|
Hi @ms-zhenhua , thanks for reviewing! I have updated the code, please kindly take another look. |
website/docs/r/network_manager_ipam_pool_static_cidr.html.markdown
Outdated
Show resolved
Hide resolved
…down Co-authored-by: Zhenhua Hu <zhhu@microsoft.com>
ms-zhenhua
left a comment
There was a problem hiding this comment.
Hi @teowa,
Thanks for your updates. LGTM~
…m into nm_ipam_sc
| ipam_pool_id = azurerm_network_manager_ipam_pool.test.id | ||
| address_prefixes = ["10.0.0.0/26", "10.0.0.128/27"] | ||
| lifecycle { | ||
| ignore_changes = [number_of_ip_addresses_to_allocate] |
There was a problem hiding this comment.
Would an option to split this into two resources work better instead of using ignore_changes?
There was a problem hiding this comment.
Hi, I think it isn't necessary to split this into two separate resources, because it's the same resource type with the same function; only the IP address can be set from prefixes or a number.
There was a problem hiding this comment.
I have added DiffSuppressFunc to suppress the diff, ignore_changes is not needed now.
…erm into nm_ipam_sc
…m into nm_ipam_sc
…m into nm_ipam_sc
|
Hi @wyattfry , thanks for the review! The Portal UI actually maps to the |
Great point, let's go with consistency. I don't know if it would be worth mentioning anywhere that Terraform / HCL's built-in functions can be useful here, e.g. |
|
|
||
| * `address_prefixes` - (Optional) Specifies a list of IPv4 or IPv6 IP address prefixes which will be allocated to the Static CIDR. | ||
|
|
||
| -> **Note:** Exactly one of `address_prefixes` or `number_of_ip_addresses_to_allocate` must be specified. |
There was a problem hiding this comment.
For information about avoiding errors, we're trying to move everything to use the tilde + greater than combo. Not terribly important, but it would help make the docs more consistent. Don't worry about fixing this instance, just a consideration for the future.
| -> **Note:** Exactly one of `address_prefixes` or `number_of_ip_addresses_to_allocate` must be specified. | |
| ~> **Note:** Exactly one of `address_prefixes` or `number_of_ip_addresses_to_allocate` must be specified. |
|
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
New Resource:
azurerm_network_manager_ipam_pool_static_cidrPR 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_network_manager_ipam_pool_static_cidrThis 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.