- 
                Notifications
    You must be signed in to change notification settings 
- Fork 121
Closed
Closed
Copy link
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
elasticstack_kibana_action_connector returns id prefixed with space name.
To Reproduce
Steps to reproduce the behavior:
resource "elasticstack_kibana_action_connector" "opsgenie" {
  name              = "opsgenie-connector"
  connector_type_id = ".opsgenie"
  config = jsonencode({
    apiUrl = "https://api.eu.opsgenie.com"
  })
  secrets = jsonencode({
    apiKey = "redacted_api_key"
  })
}
resource "elasticstack_kibana_alerting_rule" "http_error_rate" {
  name = "http_error_rate"
  consumer = "alerts"
  notify_when = "onActiveAlert"
  params = jsonencode({
    criteria =  [{
      metric = "prometheus.http_requests_total.counter"
      comparator = ">"
      threshold = [0.3]
      timeSize = 5
      timeUnit = "m"
      aggType ="rate"
    }]
    sourceId = "default"
    filterQueryText = "prometheus.labels.status : 500"
  })
  rule_type_id = "metrics.alert.threshold"
  interval = "1m"
  enabled = true
  actions {
#    id = elasticstack_kibana_action_connector.opsgenie.id
# reference returns "default/redacted-0abd-11ee-bd9b-cbfd04361f65" while in original alert id is just "redacted-0abd-11ee-bd9b-cbfd04361f65", plan returns 404
    id = "redacted-0abd-11ee-bd9b-cbfd04361f65"
    group = "metrics.threshold.fired"
    params = jsonencode({
      subAction = "createAlert",
      subActionParams = {
        alias       = "{{rule.id}}:{{alert.id}}"
        tags        = ["{{rule.tags}}"]
        priority    = "P5",
        description = "{{rule.url}}{{context.orchestrator}}",
        message     = "500 above treshold"
      }
    })
  }
}
See the error in the output
Error: Unabled to create alerting rule
│ 
│   with elasticstack_kibana_alerting_rule.http_error_rate,
│   on opsgenie.tf line 16, in resource "elasticstack_kibana_alerting_rule" "http_error_rate":
│   16: resource "elasticstack_kibana_alerting_rule" "http_error_rate" {
│ 
│ Failed with: {"statusCode":400,"error":"Bad Request","message":"Failed to load action default/redacted-0abd-11ee-bd9b-cbfd04361f65 (404): Saved object [action/default/redacted-0abd-11ee-bd9b-cbfd04361f65] not found"}
╵
Expected behavior
id param of elasticstack_kibana_alerting_rule would accept reference from elasticstack_kibana_action_connector.
Versions (please complete the following information):
terraform -version
Terraform v1.4.6
on darwin_arm64
+ provider registry.terraform.io/elastic/ec v0.7.0
+ provider registry.terraform.io/elastic/elasticstack v0.6.1
Elastic version: 8.8.1 cloud deployed.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working