BetterStackHQ/terraform-provider-better-uptime

Updating betteruptime_status_page_resource fails

Closed this issue · 2 comments

I have successfully deployed a status page with a new Edge-based monitor of type v2:

resource "betteruptime_monitor" "CoapIpv4" {
  checks_version       = "v2"
  ip_version           = "ipv4"
  url                  = "coap.${var.host}"
  port                 = "5684"
  monitor_type         = "udp"
  monitor_group_id     = betteruptime_monitor_group.General.id
  ...
  regions              = ["us", "eu", "as", "au"]
}

resource "betteruptime_status_page_resource" "myOrgCoaP" {
  resource_type          = "Monitor"
  resource_id            = betteruptime_monitor.CoapIpv4.id
  ...
  widget_type            = "history"
  history                = true
}

Now Im trying to replace it with a similar, Proxy-based v1 monitor:

resource "betteruptime_monitor" "CoapIpv4Proxy" {
  checks_version       = "v1"
  url                  = "coap.${var.host}"
  port                 = "5684"
  monitor_type         = "udp"
  monitor_group_id     = betteruptime_monitor_group.General.id
  ...
  regions              = ["us", "eu", "as", "au"]
}

# Only resource_id changed:
resource "betteruptime_status_page_resource" "myOrgCoaP" {
  resource_type          = "Monitor"
  resource_id            = betteruptime_monitor.CoapIpv4Proxy.id
  ...
  widget_type            = "history"
  history                = true
}

terraform plan shows:

  # betteruptime_status_page_resource.myOrgCoaP will be updated in-place
  ~ resource "betteruptime_status_page_resource" "myOrgCoaP" {
        id                     = "8387136"
      ~ resource_id            = 1844499 -> 2275075
        # (10 unchanged attributes hidden)
    }

And terraform apply fails with:

betteruptime_status_page_resource.myOrgCoaP: Modifying... [id=8387136]
╷
│ Error: PATCH https://betteruptime.com/api/v2/status-pages/183276/resources/8387136 returned 422: {"errors":"Sorry, you are missing some required attributes","required_attributes":"resource_type"}
│ 
│   with betteruptime_status_page_resource.myOrgCoaP,
│   on status_pages_myorg.tf line 288, in resource "betteruptime_status_page_resource" "myOrgCoaP":
│  288: resource "betteruptime_status_page_resource" "myOrgCoaP" {

But the resource_type = "Monitor" is still there?

Hello @toha-nordic, thanks for the report!

We've managed to find the issue, and fix in the v0.10.2 release 🙌

Running terraform init --upgrade before the next apply should ensure the resource gets updated correctly 🚀

Thank you, seems to work for me now 👍