-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Address Book Terraform Plan Output Improvement #316
Comments
I can work on this if you agree to this change. |
After further investigation, it seems this isn't quite a drop in replacement, I will continue to investigate other solutions. |
This problem had already been discussed in issue #169 for the address book of zones. For example, if I active resource "junos_security_address_book" "testman_secglobpolicy" {
network_address {
name = "red"
value = "192.0.2.3/32"
}
network_address {
name = "green"
value = "192.0.2.3/32"
}
# network_address {
# name = "blue"
# value = "192.0.2.1/32"
# }
address_set {
name = "colorall"
address = ["green", "red"]
# address = ["green", "red", "blue"]
}
} With "Block List", the output is : # junos_security_address_book.testman_secglobpolicy will be updated in-place
~ resource "junos_security_address_book" "testman_secglobpolicy" {
id = "global"
name = "global"
# (1 unchanged attribute hidden)
~ address_set {
~ address = [
+ "blue",
# (2 unchanged elements hidden)
]
name = "colorall"
# (1 unchanged attribute hidden)
}
+ network_address {
+ name = "blue"
+ value = "192.0.2.1/32"
}
# (2 unchanged blocks hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy. But with "Block Set", the output is : # junos_security_address_book.testman_secglobpolicy will be updated in-place
~ resource "junos_security_address_book" "testman_secglobpolicy" {
id = "global"
name = "global"
# (1 unchanged attribute hidden)
+ address_set {
+ address = [
+ "blue",
+ "green",
+ "red",
]
+ address_set = []
+ name = "colorall"
}
- address_set {
- address = [
- "green",
- "red",
] -> null
- address_set = [] -> null
- name = "colorall" -> null
}
+ network_address {
+ name = "blue"
+ value = "192.0.2.1/32"
}
- network_address {
- name = "green" -> null
- value = "192.0.2.3/32" -> null
}
- network_address {
- name = "red" -> null
- value = "192.0.2.3/32" -> null
}
+ network_address {
+ name = "green"
+ value = "192.0.2.3/32"
}
+ network_address {
+ name = "red"
+ value = "192.0.2.3/32"
}
}
Plan: 0 to add, 1 to change, 0 to destroy. After investigation, I think there is a bug in Terraform (core or sdk) that detects a change between empty values in the state and undefined optional arguments in the configuration. Customize hash of block with SchemaSetFunc doesn't work to avoid this bug. We will probably have to wait for the new plugin terraform-plugin-framework to resolve this bug. But if I define empty value on all optional arguments not used of blocks in the configuration, unchanged blocks are correctly hidden. For example, I add the optional argument resource "junos_security_address_book" "testman_secglobpolicy" {
network_address {
name = "red"
value = "192.0.2.3/32"
description = ""
}
network_address {
name = "green"
value = "192.0.2.3/32"
description = ""
}
network_address {
name = "blue"
value = "192.0.2.1/32"
description = ""
}
address_set {
name = "colorall"
#address = ["green", "red"]
address = ["green", "red", "blue"]
}
} I have this better output : # junos_security_address_book.testman_secglobpolicy will be updated in-place
~ resource "junos_security_address_book" "testman_secglobpolicy" {
id = "global"
name = "global"
# (1 unchanged attribute hidden)
+ address_set {
+ address = [
+ "blue",
+ "green",
+ "red",
]
+ address_set = []
+ name = "colorall"
}
- address_set {
- address = [
- "green",
- "red",
] -> null
- address_set = [] -> null
- name = "colorall" -> null
}
+ network_address {
+ name = "blue"
+ value = "192.0.2.1/32"
}
# (2 unchanged blocks hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy. So finally I will change my mind, I'll take care of switching blocks to unordered (Block Set) for address-book global and in zones, and add a note in documentation to encourage to set empty values on optional unused arguments to avoid large update plan output with unchanged blocks not correctly hidden. |
The outputs of the update plan will be different, see the note in the documentation to prevent unchanged blocks not being correctly hidden. Fix #316
Finally, after some tests, I found another solution to avoid large outputs on the update plan. |
We have been experiencing issues with large plan diffs, especially when adding a new address to the global address book. We have found that the address book operates more list an ordred list, when in all actuality, it should operate more as an unordered set.
Terraform Version: v1.0.11
Junos Device: vSRX
Error/Issue:
After applying the configuration once, then moving the order of the objects yields the following plan diff.
I have tested using
TypeSet
instead ofTypeList
for thenetwork_address
, and it appears to work well as a drop in replacement that resolves this issue.I propose changing these types of objects to sets, which will help make the plan output more accurate.
The text was updated successfully, but these errors were encountered: