-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
NSG security_rule diff are too big when optional properties are not defined #5819
Comments
This comment has been minimized.
This comment has been minimized.
@magodo unfortunately that won't work since this response is intentionally unordered in the Azure API |
@tombuildsstuff |
According to me there are two problems:
@tombuildsstuff I tried to do this: I made that to generate a uniq id based on a tuple of properties that are uniq in 1zure (direction and priority). I hoped terraform mechanism would use that to generate "In set item" property diff instead of removing the set item to replace it by a new one. This does not seem to work. If you can enlighten me about the purpose of the |
I also tried to order the security_rules based on the uniqness of It does not reflect in the plan output. |
I also tried to define the Set function. It turns out this function doesn't only compute the index of item in set, but also used to tell whether the element has been changed. So if you hash by "direction", then you have to modify "direction" so that terraform can pick up the diff. Another clue is that terraform support nil value in root level propert, but doesn't for nested property. So if, for instance, "destination_port_range" is not set at all, it will be stored as empty string in state file (the reason is because of resource data implementation for |
Absolutely, I think the schema really needs something like a |
Hi @sylr
You are right, but only for When generating the plan, terraform will ultimately call diffString to resolve the attribute diff for string fields of So sounds like that will happen in any case, even a Addtionally, this doesn't apply to An easy way to fix this is to set the |
There is a related issue in core: hashicorp/terraform#21901 |
This work around does work. I was able to only get the actual changes to show by setting the "" or [] values instead of leaving them blank! |
Since this issue seems to have been addressed in the latest versions of the provider (or a valid workaround was provided) - I'm going to close it. Please open a new updated bug report if this is still relevant. Thank you. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Terraform (and AzureRM Provider) Version
Affected Resource(s)
azurerm_network_security_group
Terraform Configuration Files
Expected Behavior
A change in a security_rule of a NSG should display a diff explaining that only the modified security_rule will be modified
Actual Behavior
The security_rule sets are composed of mutually exclusive properties:
source_address_prefix
(string) /source_address_prefixes
([]string)source_port_range
(string) /source_port_ranges
([]string)destination_address_prefix
(string) /destination_address_prefixes
([]string)destination_port_range
(string) /destination_port_ranges
([]string)If you modify a NSG which is composed of several rules with ones using the string version and others using []string versions of the properties without explicitly define is counter part as empty, the slight modification of a rule will output a plan that tells you he is about to updates almost all the security_rules.
Steps to Reproduce
terraform apply
the NSG I gave soonerterraform plan
I believe the problem comes from the fact that terraform diff engine treat
nil
and""
as being different but Azure does not.The other way to look at it is the terraform azure provider does not instanciate as it should the optional values of the
security_rule
set.Regards.
The text was updated successfully, but these errors were encountered: