Open Starimmigrant opened 1 week ago
Hello @Starimmigrant thank you for a thorough report!
You're right, DestinationPort
and SourcePort
are not set to omitempty
for a reason (changing from tcp
to icmp
requires explicitly defining destination and source port as nil
).
Fix will be ready on next release.
Hi, we encountered a bug with the
opentelekomcloud_fw_rule_v2
resource. When changing thedescription
or theSourceIPAddress/DestinationIPAddress
, the firewall rule will be updated, but thesource_port/destination_port
will also be set toany
instead of the defined port in the resource. Executingterraform apply
a second time sets the ports fromany
to the specified port again.This behavior can be potentially dangerous, as you can imagine.
Terraform provider version
Terraform v1.8.5 on linux_amd64 provider registry.terraform.io/opentelekomcloud/opentelekomcloud v1.36.12.
Affected Resource(s)
Terraform Configuration Files
Steps to Reproduce
We suspect that changing other attribute parameters, except
description
and thesource_ip_address/destination_ip_address
, will still trigger this bug.To reproduce the bug, apply the Terraform code once and then change any of the aforementioned parameters. In my example, I changed the
description
by adding some spaces to the string.Then, I applied the code again and received this output:
As you can see, the port is missing and needs to be added again. I also checked the OTC console, and the ports are set to
any
!Important Factoids
I think the issue can be found here
In the struct where
DestinationPort
andSourcePort
are defined, you can see that these are the only ones where theomitempty
tag is missing. I don't know if it's by mistake or for a reason.When the resource is updated here the values for
DestinationPort
andSourcePort
are set to nil instead of being left unchanged.