dynatrace-oss / terraform-provider-dynatrace

Apache License 2.0
70 stars 33 forks source link

User friendly name for locations used in the resource `dynatrace_http_monitor` #182

Closed jeevanions closed 1 year ago

jeevanions commented 1 year ago

Is your feature request related to a problem? Please describe. It would be good to have a user friendly name' are used in the dynatrace_http_monitor resource. At the moment the list of locations are not easily accessible and not user friendly.

resource "dynatrace_http_monitor" "dvm_web_ui_ssl_cert_expiry_http_monitor" {
  name      = "DVM-Web-UI-SSL-Cert-expiry-${var.envType}"
  enabled   = true
  frequency = 60
  locations = ["GEOLOCATION-F15152A6A059C277", "GEOLOCATION-A65079A417EA8B42"]
  anomaly_detection {
    loading_time_thresholds {
      enabled = true
      thresholds {
        threshold {
          type          = "ACTION"
          request_index = 1
          value_ms      = 20000
        }
      }
    }
....
}

Describe the solution you'd like If we can make the locations names user friendly like eastus, uksouth, etc that would make it more easy to use this. Moreover the documentation doesn't give you an example of resources with all its dependencies.

I propose to have something like this.

resource "dynatrace_http_monitor" "dvm_web_ui_ssl_cert_expiry_http_monitor" {
  name      = "DVM-Web-UI-SSL-Cert-expiry-${var.envType}"
  enabled   = true
  frequency = 60
  locations = ["eastus","uksouth"]
  anomaly_detection {
    loading_time_thresholds {
      enabled = true
      thresholds {
        threshold {
          type          = "ACTION"
          request_index = 1
          value_ms      = 20000
        }
      }
    }
....
}

Describe alternatives you've considered We at the moment use the export utility to get the location name and update the terraform resource.

Additional context NA

Dynatrace-Reinhard-Pilz commented 1 year ago

Hello @jeevanions

You can use the data source dynatrace_synthetic_location to make things a bit more readable - like in this example.

data "dynatrace_synthetic_location" "CapeTown" {
  cloud_platform = "AZURE"
  type           = "PUBLIC"
  name           = "Cape Town"
}

resource "dynatrace_http_monitor" "TerraTest" {
  name      = "TerraTest2"
  enabled   = true
  frequency = 1
  locations = [ data.dynatrace_synthetic_location.CapeTown.id ]
  anomaly_detection {
    loading_time_thresholds {
      enabled = true
    }
    outage_handling {
      global_outage  = true
      local_outage   = false
      retry_on_error = false
      global_outage_policy {
        consecutive_runs = 1
      }
    }
  }
  script {
    request {
      description = "google.at"
      method      = "GET"
      url         = "http://www.google.at/"
      configuration {
        accept_any_certificate = true
        follow_redirects       = true
      }
      validation {
        rule {
          type          = "httpStatusesList"
          pass_if_found = false
          value         = ">=400"
        }
      }
    }
  }
}

The data source dynatrace_synthetic_locations (with an s at the end) would also be an option here. While dynatrace_synthetic_location delivers only the first match, dynatrace_synthetic_locations provides a list of locations.