[datadog_synthetics_test] prevent overriding the local state element from the backend response #2460
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.
The
element
field of a browser test step contains the element locator, which auto-heals on the backend side, and constantly changes independently from any changes on the terraform config. Because of that, terraform is constantly prompting about these changes, which are confusing since these changes are not initiated by the user.In response to this, we disabled the diff on the
element
field, preventing terraform from updating the element at all: #854.We also introduced
force_element_update
to allow users to force updating theelement
if desired.However the initial implementation didn't prevent the state from being updated when applying the config with other changes. The undesired diff kept reappearing. Moreover,
force_element_update
will always update the online resource, giving a false sense that the resource was modified.This PR now prevents terraform from overriding the
browser_step.*.params.element
field in the local state with the response from the backend at all.If
force_element_update
is set to true, it'll still keep in state the value from the config to track changes in the config.If
force_element_update
is not set or set tofalse
, terraform will just ignore theelement
part from the backend entirely.If
force_element_update
is set totrue
, terraform won't prompt for any changes ofelement
from the backend, and will update the online resource at every apply.