tailscale/terraform-provider-tailscale

Inconsistent subscription types in the webhook resource

Closed this issue · 4 comments

Describe the bug

I am attempting to model my existing tailnet configuration in terraform. I've imported my current webhook configuration, which left me with this plan:

  # module.tailnet.tailscale_webhook.discord must be replaced
-/+ resource "tailscale_webhook" "discord" {
      ~ id            = "wQRtqs3CNTRL" -> (known after apply)
      - provider_type = "discord" -> null # forces replacement
      + secret        = (sensitive value)
      - subscriptions = [
          - "categoryDeviceMisconfigurations",
          - "categoryTailnetManagement",
        ] -> null
        # (1 unchanged attribute hidden)

So, I updated my terraform to add those:

resource "tailscale_webhook" "discord" {
  endpoint_url = var.discord_webhook_url
  subscriptions = [
    "categoryDeviceMisconfigurations",
    "categoryTailnetManagement"
  ]
}

And now my plan results in an error:

│ Error: expected subscriptions.0 to be one of ["nodeCreated" "nodeNeedsApproval" "nodeApproved" "nodeKeyExpiringInOneDay" "nodeKeyExpired" "nodeDeleted" "policyUpdate" "userCreated" "userNeedsApproval" "userSuspended" "userRestored" "userDeleted" "userApproved" "userRoleUpdated" "subnetIPForwardingNotEnabled" "exitNodeIPForwardingNotEnabled"], got categoryDeviceMisconfigurations
│
│   with module.tailnet.tailscale_webhook.discord,
│   on tailnet/tailnet.tf line 3, in resource "tailscale_webhook" "discord":
│    3:   subscriptions = [
│    4:     "categoryDeviceMisconfigurations",
│    5:     "categoryTailnetManagement"
│    6:   ]
$ terraform version
Terraform v1.3.6
on darwin_arm64
... other providers
+ provider registry.terraform.io/tailscale/tailscale v0.17.0

(Note; I upgraded terraform to 1.9.5 and no difference)

@offbyone thank you for reporting this! Looks like we missed adding proper support for category groupings for events when we added the webhook resource. Will look into fixing this.

@offbyone we've just released a v0.17.1 of the provider which should have a fix for this.

Thanks! I've updated to 0.17.1 and it's all gravy now. I much appreciate the quick turnaround.