logicmonitor / terraform-provider-logicmonitor

Terraform LogicMonitor provider.
https://registry.terraform.io
Mozilla Public License 2.0
24 stars 16 forks source link

Unable to update existing websites using 2.0.17 provider. #102

Open AntonSynchrofazatron opened 4 months ago

AntonSynchrofazatron commented 4 months ago

I am able to create new websites using the code below. But i am not able to update existing websites using code below. (Plan and error are below code).

Resource code

resource "logicmonitor_website" "prd" {
  for_each = {
    for item in local.websites_list :

    "${item.brand}-${item.region}-${item.tier}-${item.env}-${item.tenant}-${item.service}" => {
      brand         = item.brand
      region        = item.region
      tier          = item.tier
      env           = item.env
      tenant        = item.tenant
      service_url   = item.service_url
      single_tenant = item.single_tenant
      service       = item.service
      suburls       = item.suburls
      group_code    = "${item.brand}-${item.region}-${item.tier}-${item.env}"
    }
    if item.tier == "PRD"
  }

  description                = ""
  disable_alerting           = false
  schema                     = "https"
  domain                     = each.value.service_url
  global_sm_alert_cond       = 0
  group_id                   = logicmonitor_website_group.env-tenant[each.value.single_tenant ? "${each.value.group_code}-Single" : "${each.value.group_code}-${each.value.tenant}"].id
  host                       = ""
  individual_alert_level     = "warn"
  individual_sm_alert_enable = false
  is_internal                = false
  name                       = upper("${each.value.tenant}-${each.value.tier}-${each.value.env} ${each.value.service}")
  overall_alert_level        = "critical"
  polling_interval           = 1
  steps = flatten([
    length(each.value.suburls) > 0 ?
    [
      for suburl in { for t in toset(each.value.suburls) : t => t } :
      {
        schema              = "https"
        resp_type           = "config"
        timeout             = 30
        match_type          = "plain"
        description         = ""
        use_default_root    = true
        http_method         = "GET"
        enable              = true
        http_version        = "1.1"
        follow_redirection  = true
        post_data_edit_type = ""
        name                = "__step${index(each.value.suburls, suburl)}"
        req_type            = "config"
        fullpage_load       = false
        status_code         = ""
        url                 = suburl
        require_auth = false
        auth = [{ password  = "", type      = "basic", domain    = "", user_name = "", }]
        http_body    = ""
        http_headers = ""
        invert_match = false
        keyword      = ""
        label        = ""
        path         = ""
        req_script   = ""
        resp_script  = ""
        type         = "config"
      }
      ] : [
      {
        schema              = "https"
        resp_type           = "config"
        timeout             = 30
        match_type          = "plain"
        description         = ""
        use_default_root    = true
        http_method         = "GET"
        enable              = true
        http_version        = "1.1"
        follow_redirection  = true
        post_data_edit_type = ""
        name                = "__step0"
        req_type            = "config"
        fullpage_load       = false
        status_code         = ""
        url                 = ""
        require_auth = false
        auth = [{
          password  = ""
          type      = "basic"
          domain    = ""
          user_name = ""
        }]
        http_body    = ""
        http_headers = ""
        invert_match = false
        keyword      = ""
        label        = ""
        path         = ""
        req_script   = ""
        resp_script  = ""
        type         = "config"
      }
    ]
  ])

  stop_monitoring                = false
  transition                     = 1
  type                           = "webcheck"
  use_default_alert_setting      = false
  use_default_location_setting   = true
  user_permission                = "write"
  trigger_s_s_l_expiration_alert = true
  trigger_s_s_l_status_alert     = true
  alert_expr                     = "< 30 15"
  ignore_s_s_l                   = true
  test_location                  = [
      {
         all           = true
         collector_ids = []
         collectors    = []
         smg_ids       = [2,3,4,5,6,]
       },
    ]
  lifecycle {
    ignore_changes = [
      steps,
    ]
  }
}

Please note that lifecycle { ignore_changes = [ steps, ] is present only because of https://github.com/logicmonitor/terraform-provider-logicmonitor/issues/101

My plan

Terraform will perform the following actions:

  # logicmonitor_website.prd["UQ-NA-PRD-CMN-UQCA-api"] will be updated in-place
  ~ resource "logicmonitor_website" "prd" {
        id                             = "2036"
      ~ name                           = "UQCA-PRD API" -> "UQCA-PRD-CMN API"
        # (26 unchanged attributes hidden)
    }

  # logicmonitor_website.prd["UQ-NA-PRD-CMN-UQCA-css"] will be updated in-place
  ~ resource "logicmonitor_website" "prd" {
        id                             = "1104"
      ~ name                           = "UQCA-PRD CSS" -> "UQCA-PRD-CMN CSS"
        # (26 unchanged attributes hidden)
    }

  # logicmonitor_website.prd["UQ-NA-PRD-CMN-UQCA-logs"] will be updated in-place
  ~ resource "logicmonitor_website" "prd" {
        id                             = "1105"
      ~ name                           = "UQCA-PRD LOGS" -> "UQCA-PRD-CMN LOGS"
        # (26 unchanged attributes hidden)
    }

  # logicmonitor_website.prd["UQ-NA-PRD-CMN-UQCA-tss"] will be updated in-place
  ~ resource "logicmonitor_website" "prd" {
        id                             = "1106"
      ~ name                           = "UQCA-PRD TSS" -> "UQCA-PRD-CMN TSS"
        # (26 unchanged attributes hidden)
    }

  # logicmonitor_website.prd["UQ-NA-PRD-CMN-UQCA-urlmap"] will be updated in-place
  ~ resource "logicmonitor_website" "prd" {
        id                             = "1107"
      ~ name                           = "UQCA-PRD URLMAP" -> "UQCA-PRD-CMN URLMAP"
        # (26 unchanged attributes hidden)
    }

  # logicmonitor_website.prd["UQ-NA-PRD-CMN-UQUS-api"] will be updated in-place
  ~ resource "logicmonitor_website" "prd" {
        id                             = "2035"
      ~ name                           = "UQUS-PRD API" -> "UQUS-PRD-CMN API"
        # (26 unchanged attributes hidden)
    }

  # logicmonitor_website.prd["UQ-NA-PRD-CMN-UQUS-css"] will be updated in-place
  ~ resource "logicmonitor_website" "prd" {
        id                             = "647"
      ~ name                           = "UQUS-PRD CSS" -> "UQUS-PRD-CMN CSS"
        # (26 unchanged attributes hidden)
    }

  # logicmonitor_website.prd["UQ-NA-PRD-CMN-UQUS-logs"] will be updated in-place
  ~ resource "logicmonitor_website" "prd" {
        id                             = "648"
      ~ name                           = "UQUS-PRD LOGS" -> "UQUS-PRD-CMN LOGS"
        # (26 unchanged attributes hidden)
    }

  # logicmonitor_website.prd["UQ-NA-PRD-CMN-UQUS-tss"] will be updated in-place
  ~ resource "logicmonitor_website" "prd" {
        id                             = "649"
      ~ name                           = "UQUS-PRD TSS" -> "UQUS-PRD-CMN TSS"
        # (26 unchanged attributes hidden)
    }

  # logicmonitor_website.prd["UQ-NA-PRD-CMN-UQUS-urlmap"] will be updated in-place
  ~ resource "logicmonitor_website" "prd" {
        id                             = "650"
      ~ name                           = "UQUS-PRD URLMAP" -> "UQUS-PRD-CMN URLMAP"
        # (26 unchanged attributes hidden)
    }

Plan: 0 to add, 10 to change, 0 to destroy.

Expected changes are applied. Actual:

Plan: 0 to add, 10 to change, 0 to destroy.

Do you want to perform these actions in workspace "UQNA-PRD-CMN"?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

logicmonitor_website.prd["UQ-NA-PRD-CMN-UQCA-tss"]: Modifying... [id=1106]
logicmonitor_website.prd["UQ-NA-PRD-CMN-UQCA-css"]: Modifying... [id=1104]
logicmonitor_website.prd["UQ-NA-PRD-CMN-UQUS-urlmap"]: Modifying... [id=650]
logicmonitor_website.prd["UQ-NA-PRD-CMN-UQUS-tss"]: Modifying... [id=649]
logicmonitor_website.prd["UQ-NA-PRD-CMN-UQUS-api"]: Modifying... [id=2035]
logicmonitor_website.prd["UQ-NA-PRD-CMN-UQCA-logs"]: Modifying... [id=1105]
logicmonitor_website.prd["UQ-NA-PRD-CMN-UQUS-css"]: Modifying... [id=647]
logicmonitor_website.prd["UQ-NA-PRD-CMN-UQCA-api"]: Modifying... [id=2036]
logicmonitor_website.prd["UQ-NA-PRD-CMN-UQCA-urlmap"]: Modifying... [id=1107]
logicmonitor_website.prd["UQ-NA-PRD-CMN-UQUS-logs"]: Modifying... [id=648]
╷
│ Error: unexpected: [PUT /website/websites/{id}][400] updateWebsiteById default  &{ErrorCode:1400 ErrorDetail:<nil> ErrorMessage:Invalid type}
│
│   with logicmonitor_website.prd["UQ-NA-PRD-CMN-UQUS-logs"],
│   on lm_websites.tf line 3, in resource "logicmonitor_website" "prd":
│    3: resource "logicmonitor_website" "prd" {
│
╵
╷
│ Error: unexpected: [PUT /website/websites/{id}][400] updateWebsiteById default  &{ErrorCode:1400 ErrorDetail:<nil> ErrorMessage:Invalid type}
│
│   with logicmonitor_website.prd["UQ-NA-PRD-CMN-UQUS-css"],
│   on lm_websites.tf line 3, in resource "logicmonitor_website" "prd":
│    3: resource "logicmonitor_website" "prd" {
│
╵
╷
│ Error: unexpected: [PUT /website/websites/{id}][400] updateWebsiteById default  &{ErrorCode:1400 ErrorDetail:<nil> ErrorMessage:Invalid type}
│
│   with logicmonitor_website.prd["UQ-NA-PRD-CMN-UQCA-tss"],
│   on lm_websites.tf line 3, in resource "logicmonitor_website" "prd":
│    3: resource "logicmonitor_website" "prd" {
│
╵
╷
│ Error: unexpected: [PUT /website/websites/{id}][400] updateWebsiteById default  &{ErrorCode:1400 ErrorDetail:<nil> ErrorMessage:Invalid type}
│
│   with logicmonitor_website.prd["UQ-NA-PRD-CMN-UQCA-urlmap"],
│   on lm_websites.tf line 3, in resource "logicmonitor_website" "prd":
│    3: resource "logicmonitor_website" "prd" {
│
╵
╷
│ Error: unexpected: [PUT /website/websites/{id}][400] updateWebsiteById default  &{ErrorCode:1400 ErrorDetail:<nil> ErrorMessage:Invalid type}
│
│   with logicmonitor_website.prd["UQ-NA-PRD-CMN-UQUS-urlmap"],
│   on lm_websites.tf line 3, in resource "logicmonitor_website" "prd":
│    3: resource "logicmonitor_website" "prd" {
│
╵
╷
│ Error: unexpected: [PUT /website/websites/{id}][400] updateWebsiteById default  &{ErrorCode:1400 ErrorDetail:<nil> ErrorMessage:Invalid type}
│
│   with logicmonitor_website.prd["UQ-NA-PRD-CMN-UQUS-api"],
│   on lm_websites.tf line 3, in resource "logicmonitor_website" "prd":
│    3: resource "logicmonitor_website" "prd" {
│
╵
╷
│ Error: unexpected: [PUT /website/websites/{id}][400] updateWebsiteById default  &{ErrorCode:1400 ErrorDetail:<nil> ErrorMessage:Invalid type}
│
│   with logicmonitor_website.prd["UQ-NA-PRD-CMN-UQCA-css"],
│   on lm_websites.tf line 3, in resource "logicmonitor_website" "prd":
│    3: resource "logicmonitor_website" "prd" {
│
╵
╷
│ Error: unexpected: [PUT /website/websites/{id}][400] updateWebsiteById default  &{ErrorCode:1400 ErrorDetail:<nil> ErrorMessage:Invalid type}
│
│   with logicmonitor_website.prd["UQ-NA-PRD-CMN-UQUS-tss"],
│   on lm_websites.tf line 3, in resource "logicmonitor_website" "prd":
│    3: resource "logicmonitor_website" "prd" {
│
╵
╷
│ Error: unexpected: [PUT /website/websites/{id}][400] updateWebsiteById default  &{ErrorCode:1400 ErrorDetail:<nil> ErrorMessage:Invalid type}
│
│   with logicmonitor_website.prd["UQ-NA-PRD-CMN-UQCA-api"],
│   on lm_websites.tf line 3, in resource "logicmonitor_website" "prd":
│    3: resource "logicmonitor_website" "prd" {
│
╵
╷
│ Error: unexpected: [PUT /website/websites/{id}][400] updateWebsiteById default  &{ErrorCode:1400 ErrorDetail:<nil> ErrorMessage:Invalid type}
│
│   with logicmonitor_website.prd["UQ-NA-PRD-CMN-UQCA-logs"],
│   on lm_websites.tf line 3, in resource "logicmonitor_website" "prd":
│    3: resource "logicmonitor_website" "prd" {
│
╵
lm-madhvi commented 3 months ago

Hi @AntonSynchrofazatron ,

As I can see you are getting error invalid type , which is a bad request message on our side. Please recheck the resource configuration code.

AntonSynchrofazatron commented 2 months ago

hello @lm-madhvi . the problem is i can create the resource without any issues with code provided above. But trying to update the resource with any kind of change results in error. And "type" is used in several places .. so how to guess which one is wrong ( it is weird though that it allows to create a resource).