logdna / terraform-provider-logdna

Terraform provider to simplify creation of views, preset alerts and other resources in LogDNA!
https://registry.terraform.io/providers/logdna/logdna/latest
MIT License
11 stars 12 forks source link

Attaching alert while creating view does not work as documented #47

Open philippfrank opened 2 years ago

philippfrank commented 2 years ago

This does not work (1.8.0):

https://github.com/logdna/terraform-provider-logdna/blame/main/docs/data-sources/logdna_alert.md#L80

│ Error: Unsupported argument
│
│   on main.tf line 101, in resource "logdna_view" "test":
│  101:   slack_channel = data.logdna_alert.test_alert.slack_channel
│
│ An argument named "slack_channel" is not expected here. Did you mean to define a block of
│ type "slack_channel"?
jakedipity commented 2 years ago

Looks like we need to update our documentation. The correct way to fill in a block from a source is with a dynamic block e.g.

resource "logdna_view" "test" {
  name  = "Basic View"
  query = "level:debug my query"
  dynamic email_channel {
    for_each = data.logdna_alert.external_remote.email_channel
    content {
      immediate       = email_channel.value["immediate"]
      operator        = email_channel.value["operator"]
      terminal        = email_channel.value["terminal"]
      triggerinterval = email_channel.value["triggerinterval"]
      triggerlimit    = email_channel.value["triggerlimit"]
      emails          = email_channel.value["emails"]
    }
  }
}
philippfrank commented 2 years ago

@jakedipity - yes, that works - thank you. Please update the docs, other folks were having the same or related issues:

cc https://github.com/logdna/terraform-provider-logdna/issues/44 https://github.com/logdna/terraform-provider-logdna/issues/26

selva-krishnan commented 2 years ago

@philippfrank - This fix does not attach the preset to the view. Instead, it creates as a view specific alert. I was expecting to see something like a preset and used by multiple views in the LogDNA UI