Skip to content

Commit

Permalink
[U-3628] Add resource for outgoing_webhooks (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
iatanas0v authored Nov 7, 2024
1 parent 3c53720 commit 282f4cc
Show file tree
Hide file tree
Showing 6 changed files with 764 additions and 0 deletions.
59 changes: 59 additions & 0 deletions docs/resources/betteruptime_outgoing_webhook.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "betteruptime_outgoing_webhook Resource - terraform-provider-better-uptime"
subcategory: ""
description: |-
https://betterstack.com/docs/uptime/api/outgoing-webhook-integrations/
---

# betteruptime_outgoing_webhook (Resource)

https://betterstack.com/docs/uptime/api/outgoing-webhook-integrations/



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- **trigger_type** (String) The type of trigger for the webhook. Only settable during creation. Available values: `incident_change`, `on_call_change`, `monitor_change`.
- **url** (String) The URL to send webhooks to.

### Optional

- **custom_webhook_template_attributes** (Block List, Max: 1) Custom webhook template configuration. (see [below for nested schema](#nestedblock--custom_webhook_template_attributes))
- **name** (String) The name of the outgoing webhook.
- **on_incident_acknowledged** (Boolean) Whether to trigger webhook when incident is acknowledged. Only when `trigger_type=incident_change`.
- **on_incident_resolved** (Boolean) Whether to trigger webhook when incident is resolved. Only when `trigger_type=incident_change`.
- **on_incident_started** (Boolean) Whether to trigger webhook when incident starts. Only when `trigger_type=incident_change`.
- **team_name** (String) Used to specify the team the resource should be created in when using global tokens.

### Read-Only

- **id** (String) The ID of the outgoing webhook.

<a id="nestedblock--custom_webhook_template_attributes"></a>
### Nested Schema for `custom_webhook_template_attributes`

Optional:

- **auth_password** (String, Sensitive) The password to use for basic authentication.
- **auth_username** (String) The username to use for basic authentication.
- **body_template** (String) The body of the webhook request.
- **headers_template** (Block List) The headers to include in the webhook request. (see [below for nested schema](#nestedblock--custom_webhook_template_attributes--headers_template))
- **http_method** (String) The HTTP method to use when sending the webhook. Possible values: `get`, `post`, `put`, `patch` and `head`.

Read-Only:

- **id** (String) The ID of this resource.

<a id="nestedblock--custom_webhook_template_attributes--headers_template"></a>
### Nested Schema for `custom_webhook_template_attributes.headers_template`

Required:

- **name** (String)
- **value** (String)


39 changes: 39 additions & 0 deletions examples/advanced/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,42 @@ resource "betteruptime_severity" "this" {

severity_group_id = betteruptime_severity_group.this.id
}

resource "betteruptime_outgoing_webhook" "outgoing_webhook_1" {
name = "Terraform Outgoing Webhook 1"
url = "https://example.com"
trigger_type = "incident_change"

on_incident_started = true
on_incident_acknowledged = false
on_incident_resolved = false

custom_webhook_template_attributes {
http_method = "get"

auth_username = "user"
auth_password = "password"

headers_template {
name = "Content-Type"
value = "application/json"
}

body_template = jsonencode({
incident = {
id = "$INCIDENT_ID"
started_at = "$STARTED_AT"
}
})
}
}

resource "betteruptime_outgoing_webhook" "outgoing_webhook_2" {
name = "Terraform Outgoing Webhook 2"
url = "https://example.com"
trigger_type = "on_call_change"

custom_webhook_template_attributes {
body_template = "{\"incident\":{\"id\":\"$INCIDENT_ID\",\"started_at\":\"$STARTED_AT\"}}"
}
}
1 change: 1 addition & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func New(opts ...Option) *schema.Provider {
"betteruptime_new_relic_integration": newNewRelicIntegrationResource(),
"betteruptime_grafana_integration": newGrafanaIntegrationResource(),
"betteruptime_prometheus_integration": newPrometheusIntegrationResource(),
"betteruptime_outgoing_webhook": newOutgoingWebhookResource(),
},
ConfigureContextFunc: func(ctx context.Context, r *schema.ResourceData) (interface{}, diag.Diagnostics) {
var userAgent string
Expand Down
Loading

0 comments on commit 282f4cc

Please sign in to comment.