Skip to content

Commit

Permalink
feat(fastly_alert): align descriptions with API docs, add to interfac…
Browse files Browse the repository at this point in the history
…e test
  • Loading branch information
darin-nee committed Feb 14, 2024
1 parent 798617c commit 5306e92
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
24 changes: 12 additions & 12 deletions docs/resources/alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ resource "fastly_alert" "example" {

## Import

Fastly Alerts can be imported using their Definition ID, e.g.
Fastly Alerts can be imported using their ID, e.g.

```sh
$ terraform import fastly_alert.example xxxxxxxxxxxxxxxxxxxx
Expand All @@ -45,17 +45,17 @@ $ terraform import fastly_alert.example xxxxxxxxxxxxxxxxxxxx

### Required

- `evaluation_strategy` (Block List, Min: 1, Max: 1) Evaluation strategy for the Alert. (see [below for nested schema](#nestedblock--evaluation_strategy))
- `metric` (String) The name of the metric to monitor for Alert evaluation. For detailed information on metrics available for monitoring, see [Fastly Alerts API Documentation](https://developer.fastly.com/reference/api/observability/alerts/definition/).
- `name` (String) Summary text of the Alert.
- `service_id` (String) ID of the Fastly Service that the Alert monitors.
- `source` (String) The metric source. One of: `stats`, `origins`, `domains`.
- `evaluation_strategy` (Block List, Min: 1, Max: 1) Criteria on how to alert. (see [below for nested schema](#nestedblock--evaluation_strategy))
- `metric` (String) The metric name to alert on for a specific source: [domains](https://developer.fastly.com/reference/api/metrics-stats/domain-inspector/historical), [origins](https://developer.fastly.com/reference/api/metrics-stats/origin-inspector/historical), or [stats](https://developer.fastly.com/reference/api/metrics-stats/historical-stats).
- `name` (String) The name of the alert.
- `service_id` (String) The service which the alert monitors.
- `source` (String) The source where the metric comes from. One of: `domains`, `origins`, `stats`.

### Optional

- `description` (String) Text body included in Alert notifications.
- `dimensions` (Block List, Max: 1) Dimension filters applied to the metric. (see [below for nested schema](#nestedblock--dimensions))
- `integration_ids` (Set of String) Set of IDs of integrations that Alert notifications will be sent to.
- `description` (String) Additional text that is included in the alert notification.
- `dimensions` (Block List, Max: 1) More filters depending on the source type. (see [below for nested schema](#nestedblock--dimensions))
- `integration_ids` (Set of String) List of integrations used to notify when alert fires.

### Read-Only

Expand All @@ -67,7 +67,7 @@ $ terraform import fastly_alert.example xxxxxxxxxxxxxxxxxxxx
Required:

- `period` (String) The length of time to evaluate whether the conditions have been met. The data is polled every minute. One of: `5m`, `15m`, `30m`.
- `threshold` (Number) Threshold used to trigger.
- `threshold` (Number) Threshold used to alert.
- `type` (String) Type of strategy to use to evaluate. One of: `above_threshold`, `below_threshold`.


Expand All @@ -76,5 +76,5 @@ Required:

Optional:

- `domains` (Set of String) Names of a subset of domains defined on the service that the Alert monitors.
- `origins` (Set of String) Addresses of a subset of backends defined on the service that the Alert monitors.
- `domains` (Set of String) Names of a subset of domains that the alert monitors.
- `origins` (Set of String) Addresses of a subset of backends that the alert monitors.
22 changes: 11 additions & 11 deletions fastly/resource_fastly_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ func resourceFastlyAlert() *schema.Resource {
"description": {
Type: schema.TypeString,
Optional: true,
Description: "Text body included in Alert notifications.",
Description: "Additional text that is included in the alert notification.",
},

"dimensions": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: "Dimension filters applied to the metric.",
Description: "More filters depending on the source type.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"domains": {
Type: schema.TypeSet,
Optional: true,
Description: "Names of a subset of domains defined on the service that the Alert monitors.",
Description: "Names of a subset of domains that the alert monitors.",
Elem: &schema.Schema{Type: schema.TypeString},
},
"origins": {
Type: schema.TypeSet,
Optional: true,
Description: "Addresses of a subset of backends defined on the service that the Alert monitors.",
Description: "Addresses of a subset of backends that the alert monitors.",
Elem: &schema.Schema{Type: schema.TypeString},
},
},
Expand All @@ -52,7 +52,7 @@ func resourceFastlyAlert() *schema.Resource {
"evaluation_strategy": {
Type: schema.TypeList,
Required: true,
Description: "Evaluation strategy for the Alert.",
Description: "Criteria on how to alert.",
MinItems: 1,
MaxItems: 1,
Elem: &schema.Resource{
Expand All @@ -65,7 +65,7 @@ func resourceFastlyAlert() *schema.Resource {
"threshold": {
Type: schema.TypeFloat,
Required: true,
Description: "Threshold used to trigger.",
Description: "Threshold used to alert.",
},
"type": {
Type: schema.TypeString,
Expand All @@ -79,34 +79,34 @@ func resourceFastlyAlert() *schema.Resource {
"integration_ids": {
Type: schema.TypeSet,
Optional: true,
Description: "Set of IDs of integrations that Alert notifications will be sent to.",
Description: "List of integrations used to notify when alert fires.",
Elem: &schema.Schema{Type: schema.TypeString},
},

"metric": {
Type: schema.TypeString,
Required: true,
Description: "The name of the metric to monitor for Alert evaluation. For detailed information on metrics available for monitoring, see [Fastly Alerts API Documentation](https://developer.fastly.com/reference/api/observability/alerts/definition/).",
Description: "The metric name to alert on for a specific source: [domains](https://developer.fastly.com/reference/api/metrics-stats/domain-inspector/historical), [origins](https://developer.fastly.com/reference/api/metrics-stats/origin-inspector/historical), or [stats](https://developer.fastly.com/reference/api/metrics-stats/historical-stats).",
},

"name": {
Type: schema.TypeString,
Required: true,
Description: "Summary text of the Alert.",
Description: "The name of the alert.",
},

"service_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "ID of the Fastly Service that the Alert monitors.",
Description: "The service which the alert monitors.",
},

"source": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The metric source. One of: `stats`, `origins`, `domains`.",
Description: "The source where the metric comes from. One of: `domains`, `origins`, `stats`.",
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion templates/resources/alert.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Provides a Fastly Alert. Alerts send notifications to custom integrations (e.g.,

## Import

Fastly Alerts can be imported using their Definition ID, e.g.
Fastly Alerts can be imported using their ID, e.g.

{{ codefile "sh" "examples/resources/components/alert_import_cmd.txt" }}

Expand Down
12 changes: 12 additions & 0 deletions tests/interface/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,15 @@ resource "fastly_service_vcl" "interface-test-project" {
response_object = "test_response_object_waf"
}
}

resource "fastly_alert" "interface-test-alert" {
name = "test_alert"
service_id = fastly_service_vcl.interface-test-project.id
source = "stats"
metric = "status_5xx"

evaluation_strategy {
type = "above_threshold"
period = "5m"
threshold = 10
}

0 comments on commit 5306e92

Please sign in to comment.