Skip to content

Commit

Permalink
Add support for signl4 alarms recipient (#255)
Browse files Browse the repository at this point in the history
### WHY are these changes introduced?

'signl4' alarm recipient have been added to our backend and should be added to the provider too.

### WHAT is this pull request doing?

- Adds new  recipient type.
- Updates to docs (sort recipient by name, examples etc).
  • Loading branch information
tbroden84 authored Jan 26, 2024
1 parent fdd9829 commit 7c8e2bb
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 20 deletions.
14 changes: 8 additions & 6 deletions cloudamqp/resource_cloudamqp_notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ func resourceNotification() *schema.Resource {
Description: "Instance identifier",
},
"type": {
Type: schema.TypeString,
Required: true,
Description: "Type of the notification, valid options are: email, webhook, pagerduty, victorops, opsgenie, opsgenie-eu, slack, teams",
Type: schema.TypeString,
Required: true,
Description: "Type of the notification, valid options are: email, opsgenie, opsgenie-eu," +
"pagerduty, slack, signl4, teams, victorops, webhook",
ValidateFunc: validateNotificationType(),
},
"value": {
Expand Down Expand Up @@ -134,13 +135,14 @@ func resourceNotificationDelete(d *schema.ResourceData, meta interface{}) error
func validateNotificationType() schema.SchemaValidateFunc {
return validation.StringInSlice([]string{
"email",
"webhook",
"pagerduty",
"victorops",
"opsgenie",
"opsgenie-eu",
"pagerduty",
"signl4",
"slack",
"teams",
"victorops",
"webhook",
}, true)
}

Expand Down
117 changes: 103 additions & 14 deletions docs/resources/notification.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,44 @@ Available for all subscription plans.

## Example Usage

<details>
<summary>
<b>Email recipient</b>
</summary>

```hcl
# New recipient to receieve notifications
resource "cloudamqp_notification" "email_recipient" {
instance_id = cloudamqp_instance.instance.id
type = "email"
value = "[email protected]"
name = "alarm"
}
```

resource "cloudamqp_notification" "victorops_recipient" {
</details>

<details>
<summary>
<b>OpsGenie recipient</b>
</summary>

```hcl
resource "cloudamqp_notification" "opsgenie_recipient" {
instance_id = cloudamqp_instance.instance.id
type = "victorops"
value = "<UUID>"
name = "Victorops"
options = {
"rk" = "ROUTINGKEY"
}
type = "opsgenie" # or "opsgenie-eu"
value = "<api-key>"
name = "OpsGenie"
}
```

</details>

<details>
<summary>
<b>Pagerduty recipient</b>
</summary>

```hcl
resource "cloudamqp_notification" "pagerduty_recipient" {
instance_id = cloudamqp_instance.instance.id
type = "pagerduty"
Expand All @@ -43,6 +62,75 @@ resource "cloudamqp_notification" "pagerduty_recipient" {
}
```

</details>

<details>
<summary>
<b>Signl4 recipient</b>
</summary>

```hcl
resource "cloudamqp_notification" "signl4_recipient" {
instance_id = cloudamqp_instance.instance.id
type = "signl4"
value = "<team-secret>"
name = "Signl4"
}
```

</details>

<details>
<summary>
<b>Teams recipient</b>
</summary>

```hcl
resource "cloudamqp_notification" "teams_recipient" {
instance_id = cloudamqp_instance.instance.id
type = "teams"
value = "<teams-webhook-url>"
name = "Teams"
}
```

</details>

<details>
<summary>
<b>Victorops recipient</b>
</summary>

```hcl
resource "cloudamqp_notification" "victorops_recipient" {
instance_id = cloudamqp_instance.instance.id
type = "victorops"
value = "<integration-key>"
name = "Victorops"
options = {
"rk" = "ROUTINGKEY"
}
}
```

</details>

<details>
<summary>
<b>Webhook recipient</b>
</summary>

```hcl
resource "cloudamqp_notification" "webhook_recipient" {
instance_id = cloudamqp_instance.instance.id
type = "webhook"
value = "<webhook-url>"
name = "Webhook"
}
```

</details>

## Argument Reference

The following arguments are supported:
Expand All @@ -64,19 +152,20 @@ All attributes reference are computed
Valid options for notification type.

* email
* webhook
* pagerduty
* victorops
* opsgenie
* opsgenie-eu
* pagerduty
* signl4
* slack
* teams
* victorops
* webhook

## Options parameter

| Type | Options | Description | Note |
|-----------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
| Victorops | rk | Routing key to route alarm notification | - |
| Type | Options | Description | Note |
|---|---|---|---|
| Victorops | rk | Routing key to route alarm notification | - |
| PagerDuty | dedupkey | Default the dedup key for PagerDuty is generated depending on what alarm has triggered, but here you can set what `dedup` key to use so even if the same alarm is triggered for different resources you only get one notification. Leave blank to use the generated dedup key. | If multiple alarms are triggered using this recipient, since they all share `dedup` key only the first alarm will be shown in PagerDuty |

## Dependency
Expand Down

0 comments on commit 7c8e2bb

Please sign in to comment.