grafana / terraform-provider-grafana

Terraform Grafana provider
https://www.terraform.io/docs/providers/grafana/
Mozilla Public License 2.0
425 stars 225 forks source link

trigger_webhook missing on grafana_oncall_escalation #1012

Closed rosilva-85 closed 5 months ago

rosilva-85 commented 1 year ago

Terraform Version

Affected Resource(s)

Terraform Configuration Files

resource "grafana_oncall_escalation" "call_webhook" {
  provider = grafana.cloud
  escalation_chain_id = grafana_oncall_escalation_chain.demo.id
  type                = "trigger_webhook"
  position = 0

  depends_on = [
    grafana_oncall_escalation_chain.demo
  ]
}

Expected Behavior

Add an escalation step to call a outgoing webhook, as I can do on the ui.

Actual Behavior

The option is not available on the provider, so it breaks. If I do an import of the pre prexisting object, terraform detects it as trigger_webhook

"provider": "provider[\"registry.terraform.io/grafana/grafana\"].cloud", "instances": [ { "schema_version": 0, "attributes": { "action_to_trigger": "", "duration": 0, "escalation_chain_id": "FSN1R71", "group_to_notify": "", "id": "EWWYXWYV", "important": false, "notify_if_time_from": "", "notify_if_time_to": "", "notify_on_call_from_schedule": "", "persons_to_notify": [], "persons_to_notify_next_each_time": [], "position": 3, "type": "trigger_webhook" }

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

Try to create an escalation step based on an outgoing webhook with terraform

rosilva-85 commented 1 year ago

Seems that is not supported here:

https://github.com/grafana/terraform-provider-grafana/blob/v2.2.0/internal/resources/oncall/resource_escalation.go#L17-L28

So I think is an enhancement in this case, not a bug

holgerson97 commented 1 year ago

You want to use the trigger_action.

rosilva-85 commented 1 year ago

I have tried to use trigger_action, with no luck.

Is there any working example with trigger action to execute an external_webhook?

swxlbjs commented 1 year ago

oncall 1.3.29

set up

resource "grafana_oncall_escalation" "test" { provider = grafana.oncall escalation_chain_id = grafana_oncall_escalation_chain.test.id action_to_trigger = grafana_oncall_outgoing_webhook.test.id type = "trigger_action" position = 0 }

result

400 {action_to_trigger: [Object does not exist]}

Maybe it's a version issue ?

rosilva-85 commented 1 year ago

If you import the resource with terraform import, the type on the on call api is: "type": "trigger_webhook"

I've also tried to do it via API, but doesn't work:

{"escalation_chain_id":["Object does not exist"],"action_to_trigger":["Object does not exist"]}%

https://grafana.com/docs/oncall/latest/oncall-api-reference/escalation_policies/#create-an-escalation-policy

holgerson97 commented 1 year ago

I have the same error using the API directly, I opened a support ticket. It seems to be an issue with the API itself.

When receiving a helpful response I will inform you guys.

rosilva-85 commented 11 months ago

any update on this?

joeyorlando commented 5 months ago

hi there 👋 please try upgrading to 2.15.0 which was just released. trigger_webhook should be the correct type value for your use case here. let me know if you still face this issue.