thousandeyes / terraform-provider-thousandeyes

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

[Bug]: "mtu_measurements" ignored when creating new test resources #159

Closed omaslara closed 7 months ago

omaslara commented 8 months ago

What versions are you using?

❯ terraform version
Terraform v1.6.6
on darwin_amd64
+ provider registry.terraform.io/thousandeyes/thousandeyes v2.0.6

What did you expect to happen?

When creating new ThousandEyes tests, if the mtu_measurements parameter value is set to false, the test resources must be created with mtu_measurements=false.

What actually happened?

When creating new tests with any of the resources listed below, if the mtu_measurements parameter value is set to false, its value is ignored, and the tests are created with mtu_measurements = true.

After the test resources are created, if you run terraform apply for a 2nd time, the mtu_measurements value changes from true to false as they should be according to the Terraform configuration.

This issue happens for the following resources:

Terraform code to reproduce the bug

terraform {
  required_providers {
    thousandeyes = {
      source  = "thousandeyes/thousandeyes"
      version = ">= 2.0.6"
    }
  }
}

provider "thousandeyes" {
  token            = "your_token"
  account_group_id = "your_account_group_id"
}

data "thousandeyes_agent" "miami" {
  agent_name = "Miami, FL"
}
data "thousandeyes_agent" "tokyo" {
  agent_name = "Tokyo, Japan"
}
data "thousandeyes_agent" "chicago_webex" {
  agent_name = "Chicago, IL (Webex)"
}

resource "thousandeyes_agent_to_server" "agent_to_server_webexapi" {
  test_name        = "NPROD - Webex APIs"
  interval         = 300
  server           = "webexapis.com"
  protocol         = "TCP"
  port             = 443
  mtu_measurements = true

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

resource "thousandeyes_http_server" "http_server_google" {
  test_name        = "NPROD - Google - HTTP Server"
  interval         = 300
  mtu_measurements = false
  url              = "https://www.google.com"

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

resource "thousandeyes_dns_server" "nprod_dns_server_google" {
  test_name        = "NPROD - google.com - DNS auth"
  interval         = 300
  domain           = "google.com A"
  mtu_measurements = false

  dns_servers {
    server_name = "ns1.google.com."
  }

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

resource "thousandeyes_page_load" "nprod_page_load_google_com" {
  test_name        = "NPROD - google.com - Page Load"
  interval         = 300
  http_interval    = 300
  url              = "https://google.com"
  mtu_measurements = false

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

Any additional comments or code?

No response

Steps to reproduce the bug

  1. Apply the provided terraform configuration: terraform apply -auto-approve
  2. Check the Test > Advanced Settings in the UI to confirm the "Perform MTU measurements" is checked, when it should be unchecked.

Workaround If you want the mtu_measurements false value to be considered, run terraform apply again.

Example: The following example uses the terraform configuration provided to reproduce the issue.

❯ terraform apply -auto-approve
data.thousandeyes_agent.miami: Reading...
data.thousandeyes_agent.chicago_webex: Reading...
data.thousandeyes_agent.tokyo: Reading...
data.thousandeyes_agent.chicago_webex: Read complete after 2s [id=0xc00078b438]
data.thousandeyes_agent.miami: Read complete after 3s [id=0xc00001c9a0]
data.thousandeyes_agent.tokyo: Read complete after 3s [id=0xc000dc2d90]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # thousandeyes_agent_to_server.agent_to_server_webexapi will be created
  + resource "thousandeyes_agent_to_server" "agent_to_server_webexapi" {
      + alerts_enabled         = true
      + api_links              = (known after apply)
      + bandwidth_measurements = false
      + created_by             = (known after apply)
      + created_date           = (known after apply)
      + enabled                = true
      + groups                 = (known after apply)
      + id                     = (known after apply)
      + interval               = 300
      + live_share             = (known after apply)
      + modified_by            = (known after apply)
      + modified_date          = (known after apply)
      + network_measurements   = true
      + path_trace_mode        = "classic"
      + port                   = 443
      + probe_mode             = "AUTO"
      + protocol               = "TCP"
      + saved_event            = (known after apply)
      + server                 = "webexapis.com"
      + test_id                = (known after apply)
      + test_name              = "NPROD - Webex APIs"
      + type                   = (known after apply)
      + use_public_bgp         = false

      + agents {
          + agent_id = 275
        }
    }

  # thousandeyes_dns_server.nprod_dns_server_google will be created
  + resource "thousandeyes_dns_server" "nprod_dns_server_google" {
      + alerts_enabled         = true
      + api_links              = (known after apply)
      + bandwidth_measurements = false
      + created_by             = (known after apply)
      + created_date           = (known after apply)
      + dns_transport_protocol = "UDP"
      + domain                 = "google.com A"
      + enabled                = true
      + groups                 = (known after apply)
      + id                     = (known after apply)
      + interval               = 300
      + live_share             = (known after apply)
      + modified_by            = (known after apply)
      + modified_date          = (known after apply)
      + network_measurements   = true
      + path_trace_mode        = "classic"
      + probe_mode             = "AUTO"
      + protocol               = "TCP"
      + recursive_queries      = true
      + saved_event            = (known after apply)
      + test_id                = (known after apply)
      + test_name              = "NPROD - google.com - DNS auth"
      + type                   = (known after apply)
      + use_public_bgp         = false

      + agents {
          + agent_id = 275
        }

      + dns_servers {
          + server_name = "ns1.google.com."
        }
    }

  # thousandeyes_http_server.http_server_google will be created
  + resource "thousandeyes_http_server" "http_server_google" {
      + alerts_enabled         = true
      + api_links              = (known after apply)
      + auth_type              = "NONE"
      + bandwidth_measurements = false
      + content_regex          = ".*"
      + created_by             = (known after apply)
      + created_date           = (known after apply)
      + enabled                = true
      + follow_redirects       = true
      + groups                 = (known after apply)
      + http_target_time       = 1000
      + http_time_limit        = 5
      + http_version           = 2
      + id                     = (known after apply)
      + interval               = 300
      + live_share             = (known after apply)
      + modified_by            = (known after apply)
      + modified_date          = (known after apply)
      + network_measurements   = true
      + path_trace_mode        = "classic"
      + probe_mode             = "AUTO"
      + protocol               = "TCP"
      + saved_event            = (known after apply)
      + ssl_version            = (known after apply)
      + ssl_version_id         = 0
      + test_id                = (known after apply)
      + test_name              = "NPROD - Google - HTTP Server"
      + type                   = (known after apply)
      + url                    = "https://www.google.com"
      + verify_certificate     = true

      + agents {
          + agent_id = 275
        }
    }

  # thousandeyes_page_load.nprod_page_load_google_com will be created
  + resource "thousandeyes_page_load" "nprod_page_load_google_com" {
      + alerts_enabled         = true
      + api_links              = (known after apply)
      + auth_type              = "NONE"
      + bandwidth_measurements = false
      + content_regex          = ".*"
      + created_by             = (known after apply)
      + created_date           = (known after apply)
      + enabled                = true
      + follow_redirects       = true
      + groups                 = (known after apply)
      + http_interval          = 300
      + http_target_time       = 1000
      + http_time_limit        = 5
      + http_version           = 2
      + id                     = (known after apply)
      + include_headers        = true
      + interval               = 300
      + live_share             = (known after apply)
      + modified_by            = (known after apply)
      + modified_date          = (known after apply)
      + network_measurements   = true
      + page_load_target_time  = 6
      + page_load_time_limit   = 10
      + path_trace_mode        = "classic"
      + probe_mode             = "AUTO"
      + protocol               = "TCP"
      + saved_event            = (known after apply)
      + ssl_version            = (known after apply)
      + ssl_version_id         = 0
      + test_id                = (known after apply)
      + test_name              = "NPROD - google.com - Page Load"
      + type                   = (known after apply)
      + url                    = "https://google.com"
      + use_public_bgp         = false
      + verify_certificate     = true

      + agents {
          + agent_id = 275
        }
    }

Plan: 4 to add, 0 to change, 0 to destroy.
thousandeyes_dns_server.nprod_dns_server_google: Creating...
thousandeyes_agent_to_server.agent_to_server_webexapi: Creating...
thousandeyes_http_server.http_server_google: Creating...
thousandeyes_page_load.nprod_page_load_google_com: Creating...
thousandeyes_page_load.nprod_page_load_google_com: Creation complete after 4s [id=4533036]
thousandeyes_agent_to_server.agent_to_server_webexapi: Creation complete after 5s [id=4533037]
thousandeyes_http_server.http_server_google: Creation complete after 5s [id=4533038]
thousandeyes_dns_server.nprod_dns_server_google: Creation complete after 5s [id=4533039]

Apply complete! Resources: 4 added, 0 changed, 0 destroyed.
❯
image image image image image

Workaround

❯ terraform apply -auto-approve
data.thousandeyes_agent.miami: Reading...
data.thousandeyes_agent.tokyo: Reading...
data.thousandeyes_agent.chicago_webex: Reading...
data.thousandeyes_agent.chicago_webex: Read complete after 2s [id=0xc00089f478]
data.thousandeyes_agent.miami: Read complete after 3s [id=0xc00052d390]
thousandeyes_dns_server.nprod_dns_server_google: Refreshing state... [id=4533039]
thousandeyes_agent_to_server.agent_to_server_webexapi: Refreshing state... [id=4533037]
thousandeyes_http_server.http_server_google: Refreshing state... [id=4533038]
thousandeyes_page_load.nprod_page_load_google_com: Refreshing state... [id=4533036]
data.thousandeyes_agent.tokyo: Read complete after 3s [id=0xc000245b10]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # thousandeyes_agent_to_server.agent_to_server_webexapi will be updated in-place
  ~ resource "thousandeyes_agent_to_server" "agent_to_server_webexapi" {
        id                     = "4533037"
      ~ mtu_measurements       = true -> false
        # (22 unchanged attributes hidden)

      - alert_rules {
          - rule_id = 6884053 -> null
        }

        # (1 unchanged block hidden)
    }

  # thousandeyes_dns_server.nprod_dns_server_google will be updated in-place
  ~ resource "thousandeyes_dns_server" "nprod_dns_server_google" {
        id                     = "4533039"
      ~ mtu_measurements       = true -> false
        # (23 unchanged attributes hidden)

      - alert_rules {
          - rule_id = 6884053 -> null
        }
      - alert_rules {
          - rule_id = 6884058 -> null
        }

        # (2 unchanged blocks hidden)
    }

  # thousandeyes_http_server.http_server_google will be updated in-place
  ~ resource "thousandeyes_http_server" "http_server_google" {
        id                     = "4533038"
      ~ mtu_measurements       = true -> false
        # (30 unchanged attributes hidden)

      - alert_rules {
          - rule_id = 6884046 -> null
        }
      - alert_rules {
          - rule_id = 6884047 -> null
        }
      - alert_rules {
          - rule_id = 6884053 -> null
        }

        # (1 unchanged block hidden)
    }

  # thousandeyes_page_load.nprod_page_load_google_com will be updated in-place
  ~ resource "thousandeyes_page_load" "nprod_page_load_google_com" {
        id                     = "4533036"
      ~ mtu_measurements       = true -> false
        # (35 unchanged attributes hidden)

      - alert_rules {
          - rule_id = 6884046 -> null
        }
      - alert_rules {
          - rule_id = 6884047 -> null
        }
      - alert_rules {
          - rule_id = 6884048 -> null
        }
      - alert_rules {
          - rule_id = 6884053 -> null
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 4 to change, 0 to destroy.
thousandeyes_agent_to_server.agent_to_server_webexapi: Modifying... [id=4533037]
thousandeyes_dns_server.nprod_dns_server_google: Modifying... [id=4533039]
thousandeyes_http_server.http_server_google: Modifying... [id=4533038]
thousandeyes_page_load.nprod_page_load_google_com: Modifying... [id=4533036]
thousandeyes_page_load.nprod_page_load_google_com: Modifications complete after 4s [id=4533036]
thousandeyes_dns_server.nprod_dns_server_google: Modifications complete after 5s [id=4533039]
thousandeyes_http_server.http_server_google: Modifications complete after 5s [id=4533038]
thousandeyes_agent_to_server.agent_to_server_webexapi: Modifications complete after 5s [id=4533037]

Apply complete! Resources: 0 added, 4 changed, 0 destroyed.
❯

As seen above, the value will change for all tests: ~ mtu_measurements = true -> false.

joaomper-TE commented 7 months ago

@omaslara thanks for the detailed report!

Will close as this is a duplicate of this issue.