This is a workaround for weird API behavior when it comes to switch STP. The data is essentially a map where the key is the priority and the value is a tuple (stacks, switchProfiles, switches). But the API implements this as a list and sometimes returns multiple entries with the same priority which confuses the provider because it thinks that changes were made. In particular, the scenario that I have observed:
posted a singular object with switches, profiles and stacks
observed multiple objects returned with switches, profiles and stacks separately but the same priority
provider thinks changes were made and there is an idempotency inconsistency
The fix essentially converts the whole input data into the map, merging all the data as necessary and only then exposes the data to Terraform. No changes were necessary when converting Terraform data to the API.
This is a workaround for weird API behavior when it comes to switch STP. The data is essentially a map where the key is the priority and the value is a tuple (stacks, switchProfiles, switches). But the API implements this as a list and sometimes returns multiple entries with the same priority which confuses the provider because it thinks that changes were made. In particular, the scenario that I have observed:
The fix essentially converts the whole input data into the map, merging all the data as necessary and only then exposes the data to Terraform. No changes were necessary when converting Terraform data to the API.