thousandeyes / terraform-provider-thousandeyes

ThousandEyes Terraform Provider
Apache License 2.0
21 stars 26 forks source link

fix: alert rule and tests association #168

Closed brumarqu-te closed 3 months ago

brumarqu-te commented 3 months ago

fixes https://github.com/thousandeyes/terraform-provider-thousandeyes/issues/158 This issue is happening because we currently allow the alert rule <-> test association to be established from both perspectives. From the alert rule update perspective, it will clear any test association if the list of testIds is not sent in the request. This PR changes the alert rule test_ids schema attribute to be computed so that it is not considered in the TF plan but it's still retrieved from the alert rule get by id operation and passed along the alert rule update request. Also, since the alert rule returns a field tests when getting by id and receives a field testIds when updating the alert rule, had to implement a map from the GenericTest to get only the testId.

One drawback of this approach (not a huge one IMO) is that the state may not always be accurate. This is because a test <-> alert rules association can be changed from the test perspective and not get reflected on the alert rule perspective. Anyways, it will eventually update the state when the next alert rule update is performed.

brumarqu-te commented 3 months ago

/review @joaomper-TE @phpinhei-te @shahid-te @jabrowne-te @vascmart-te @mpragosa-te @sfreitas-te @pedro-te