fix(workflows): ignore notification trigger order when comparing state #2438
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Workflow notification triggers is an ordered set that is currently represented in Terraform as an ordered list.
Our backend does not preserve the order of the given notification triggers.
As a result, if a workflow resource notification trigger does not match the order returned by NR API, Terraform reports a state drift when there isn't any.
This PR makes sure to keep the notification trigger order the same as in the existing state.
I could not use
DiffSuppressFunc
because notification triggers are a part of another property that itself is a set. Because Terraform uses a hash of the set item as its key, if notification triggers changes, TF thinks that the entire parent set item was removed and then the new one was added. So diff suppressing would only work for the entire parent set property, which is just not really feasible and would be extremely ugly.Fixes #2433
Type of change
Please delete options that are not relevant.
Checklist:
Please delete options that are not relevant.
How to test this change?
There is an integration test that reproduces the problem.
In order to reproduce the problem manually, you need to create workflow with notification triggers in a "wrong" order.
For example,
[CLOSED, ACTIVATED]
. Without the fix, the workflow would be successfully applied, but TF would report state drift onplan