thousandeyes / terraform-provider-thousandeyes

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

BREAKING CHANGE: labels/groups attachment to tests/agents updates #125

Closed pedro-te closed 1 year ago

pedro-te commented 1 year ago

Going forward it will no longer be possible to attach a label/group to a test in any test resource. Test resources obtain the labels linked to them via the API automatically (computed fields). Labels are now linked to tests only in the label resource. This diverges from what the ThousandEyes API allows, but is necessary considering how terraform works, as it was previously possible to have a test resource cancel out a label that is being added to it in a label resource, because the test resource wasn't setting the label.

Example:

resource "thousandeyes_agent_to_server" "thousandeyes_agent_to_server_icmp_test" {
  test_name = "Pedro-test: Example Agent to Server ICMP test from Terraform provider"
  interval = 120
  alerts_enabled = false
  server = "www.thousandeyes.com"
  protocol = "ICMP"
  enabled = false

  agents {
    agent_id = X
  }
}

resource "thousandeyes_agent_to_server" "thousandeyes_agent_to_server_tcp_no_port" {
  test_name      = "Pedro-test: agent to server TCP no port from terraform provider"
  interval       = 120
  alerts_enabled = false
  use_public_bgp = false
  enabled        = false

  server = "www.thousandeyes.com"

  agents {
    agent_id = X
  }

  # BREAKING CHANGE HERE
  //groups {
  //  group_id = thousandeyes_label.pedro-label.group_id <--- # THIS IS NO LONGER POSSIBLE, THIS IS NOW A COMPUTED FIELD
  //}
}

resource "thousandeyes_label" "pedro-label" {
  name     = "Pedro - Test Label"
  type     = "tests"

  tests {
    test_id = thousandeyes_agent_to_server.thousandeyes_agent_to_server_tcp_no_port.test_id 
  }

  tests {
    test_id = thousandeyes_agent_to_server.thousandeyes_agent_to_server_icmp_test.test_id 
  }
}

Furthermore, we should merge this first: https://github.com/thousandeyes/thousandeyes-sdk-go/pull/113 And then update this PR with the new version, as this will be needed in order to support removing all agents/tests from a label. Otherwise that scenario is unsupported by our provider.

sfreitas-te commented 1 year ago

Since this is a breaking change let's first add a mention about the breaking change on the docs and afterwards remove the feature