-
Notifications
You must be signed in to change notification settings - Fork 981
Secondary pod ip ranges in SharedVPC do not conform to ordering in map #3018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Potentially related to this tf discussion question https://discuss.hashicorp.com/t/preserve-order-with-dynamic-block/50055 |
Terraform maps are always sorted alphabetically: $ terraform console
> { "b": 1 , "a": 2 }
{
"a" = 2
"b" = 1
} There is no way we can preserve the order in which it was entered. The only way to achieve what you need here, is to refactor the variable into map of objects with subnet range name and range, and use the map keys for ordering. |
Would you like me to refactor this into the subnet index list? I am willing to do this work to fix the issue we have, however it may break existing implementations as it'd be converting from map(name => iprange) to either map(number => secondary_range_object) or list(secondary_range_object). I'd be feeding the index into the key attribute of the dynamic block foreach. |
Yes that would be nice, provided the refactor really addresses the issue and does not introduce new ones :)
|
PS - Since this will also affect FAST, the change should be against the |
Affected components
The problem
When a map of secondary ip ranges is entered in the subnet module the list is ordered by alphabetical order rather than the order entered in the list in the tfvars. This means any addition with a lower letter ordering will break the secondary ip ranges already existing as it'll try to modify the existing entries to conform to alphabetical order and rename them or change the ip addresses i.e.
when a = "192.168.1.0/24" is added, even if it's added to the end of the list, it'll attempt to rename the existing members like this
Release version
v38.0.0
Terraform version
v1.10.5
Steps to reproduce
Create a subnet with the above secondary ip ranges using the above config and create it, then modify the map and you'll see the matching output.
Expected behavior
Items are mapped by their names somehow and stay in their correct ordering even after an entry is removed. Only the added or removed entries should be modified.
Actual behavior
All items get re-ordered depending on the alphabetical order.
Additional context
No response
The text was updated successfully, but these errors were encountered: