thousandeyes / terraform-provider-thousandeyes

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

Polite request for a few Label examples #122

Closed mbechc closed 9 months ago

mbechc commented 1 year ago

I'm trying hard to make test labels work. My code is as follows

resource "thousandeyes_label" "vpn_underlay" { name = "vpn_underlay" type = "tests"

tests { test_name = "cph_airport_01" agents { agent_id = data.thousandeyes_agent.underlay.agent_id } } }

If I were to create the label in gui, there is no need for agents. that is a requirement in TF - it might be the reason why I get stuck with this error.

│ Error: Failed call API endpoint. HTTP response code: 403. Error: 403 Forbidden │ Please ensure you are using the correct authentication token, and you have the correct role. │ User is not authorized to perform this operation │ │ with thousandeyes_label.vpn_underlay, │ on agent_tests.tf line 39, in resource "thousandeyes_label" "vpn_underlay": │ 39: resource "thousandeyes_label" "vpn_underlay" { │

I have found this code to create the label, but without any tests - attached.

resource "thousandeyes_label" "vpn_underlay" { name = "vpn_underlay" type = "tests" }

I would be way easier to be able to point at a test label when creating the test, I have to group/label north of 500 tests

yalbikaw-te commented 1 year ago

i am facing same issue, i hope it can be fixed soon i need for demo

josdough-te commented 1 year ago

First define your label like you mentioned in the original comment:

resource "thousandeyes_label" "label_myLabel" {
  name = "My Label Name"
  type = "tests"
}

Then inside the resource definition for your test(s), assign the label using groups:

resource "thousandeyes_http_server" "www_thousandeyes_http_test_www_amazon_com" {
  test_name      = "HTTP www.amazon.com"
  interval       = 300
  alerts_enabled = false

  groups { 
    group_id = resource.thousandeyes_label.label_myLabel.group_id
  }
  url = "https://www.amazon.com"

  agents {
    agent_id = data.thousandeyes_agent.arg_chicago.agent_id
  }
}

Make sure that no label already exists with the same name, or Terraform will not be able to create the label resource and map the label ID to the test(s).

pedro-te commented 1 year ago

Hey @mbechc and @yalbikaw-te ,

Thank you for reporting this and for bringing this to our attention.

I'm sorry that you're facing these issues with the thousandeyes_label resource. I can confirm that indeed the label resource is a bit buggy. We're working on this and will have have an update to address this soon. The fix requires us to change the behaviour of how labels are attached to tests on terraform's end, so this might take us a bit.

Thank you for your patience, Pedro

arvidsnet commented 1 year ago

looks like label assignment to agents is broken in current version

pedro-te commented 1 year ago

looks like label assignment to agents is broken in current version

Apologies for any inconvenience this might have caused. A fix for this will be released very soon, the PRs to fix this are already up.

We appreciate your patience.

pedro-te commented 1 year ago

Since the fix for this issue introduces a breaking change, we first had to release v1.3.2 which announces the deprecation of groups field in test resources. Going forward, after the new major version, it'll only be possible to assign labels to tests via the thousandeyes_label resource. We are giving our customers a 30 day grace period between these two releases.

v1.3.2 was released on the 23rd of January. The next major version, which introduces the fix for the labelling issue, will be released on the 23rd of February.

pedro-te commented 1 year ago

My apologies for the delay, but we have released version v2.0.0 which addresses this issue. We had to introduce a breaking change in order to address properly.

https://github.com/thousandeyes/terraform-provider-thousandeyes/releases/tag/v2.0.0

Please take the time to read the changes and let us know if you're still facing issues.