uptime-com / terraform-provider-uptime

A Terraform provider that provisions checks via the Uptime.com REST API
MIT License
20 stars 18 forks source link

uptime_check_api address required, but not used, resulting in permadiff #24

Closed kpocius closed 1 year ago

kpocius commented 1 year ago

uptime_check_api resource specifies that address argument is required, and in fact terraform throws an error if you don't specify it:

│ Error: Missing required argument
│
│   on uptime_check_api.tf line 1, in resource "uptime_check_api" "api":
│    1: resource "uptime_check_api" "api" {
│
│ The argument "address" is required, but no definition was found.

However, this argument does not appear to be stored in the state:

# uptime_check_api.api:
resource "uptime_check_api" "api" {
    contact_groups = [
        "Default",
    ]
    id             = "<REDACTER>"
    interval       = 3
    locations      = [
        "Austria",
        "Germany",
        "Netherlands",
        "US Central",
        "US East",
        "US West",
        "United Kingdom",
    ]
    name           = "API"
    script         = jsonencode(
        [
            {
                step_def = "C_GET"
                values   = {
                    headers = {}
                    url     = "<REDACTED>"
                }
            },
            {
                step_def = "V_HTTP_STATUS_CODE_SUCCESSFUL"
                values   = {}
            },
        ]
    )
    sensitivity    = 2
    tags           = [
        "env=prod",
    ]
    threshold      = 30
}

Which results in a permadiff when planning/applying:

Terraform will perform the following actions:

  # uptime_check_api.api will be updated in-place
  ~ resource "uptime_check_api" "api" {
      + address        = "<REDACTED>"
        id             = "<REDACTED>"
        name           = "API"
        tags           = [
            "env=prod",
        ]
        # (7 unchanged attributes hidden)
    }

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

A workaround is to ignore the changes for now, but it would be ideal if this was not necessary:

  lifecycle {
    ignore_changes = [
      address
    ]
  }
mikluko commented 1 year ago

Thanks for pointing that out. Unfortunately, with the current implementation address is a required field for all resources. The issue will be addressed in v1.5 which is a work in progress.

mikluko commented 1 year ago

@kpocius can you configrm the issue is resolved in v2.0.0-beta.1?

kpocius commented 1 year ago

Provider now fails if address is present, so it's not backwards compatible. But otherwise it seems to work fine.