Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CSGI-3062] Deprecate pagerduty_service.alert_creation attribute #835

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions pagerduty/resource_pagerduty_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func resourcePagerDutyService() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Default: "create_incidents",
// Suppressing diff since this attribute value is being enforced during
// creation to "create_alerts_and_incidents".
DiffSuppressFunc: func(k, oldValue, newValue string, d *schema.ResourceData) bool {
return true
},
ValidateDiagFunc: validateValueDiagFunc([]string{
"create_alerts_and_incidents",
"create_incidents",
Expand Down Expand Up @@ -398,9 +403,10 @@ func buildServiceStruct(d *schema.ResourceData) (*pagerduty.Service, error) {
}
}

if attr, ok := d.GetOk("alert_creation"); ok {
service.AlertCreation = attr.(string)
}
// From this point on the only allowed value for `alert_creation` will be
// "create_alerts_and_incidents", based on
// https://support.pagerduty.com/docs/alerts#enable-and-disable-alerts-on-a-service
service.AlertCreation = "create_alerts_and_incidents"

if attr, ok := d.GetOk("alert_grouping"); ok {
ag := attr.(string)
Expand Down
18 changes: 9 additions & 9 deletions pagerduty/resource_pagerduty_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestAccPagerDutyService_Basic(t *testing.T) {
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "acknowledgement_timeout", "1800"),
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "alert_creation", "create_incidents"),
"pagerduty_service.foo", "alert_creation", "create_alerts_and_incidents"),
resource.TestCheckNoResourceAttr(
"pagerduty_service.foo", "alert_grouping"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -103,7 +103,7 @@ func TestAccPagerDutyService_Basic(t *testing.T) {
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "acknowledgement_timeout", "3600"),
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "alert_creation", "create_incidents"),
"pagerduty_service.foo", "alert_creation", "create_alerts_and_incidents"),
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "incident_urgency_rule.#", "1"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -775,7 +775,7 @@ func TestAccPagerDutyService_BasicWithIncidentUrgencyRules(t *testing.T) {
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "acknowledgement_timeout", "1800"),
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "alert_creation", "create_incidents"),
"pagerduty_service.foo", "alert_creation", "create_alerts_and_incidents"),
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "incident_urgency_rule.#", "1"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -843,7 +843,7 @@ func TestAccPagerDutyService_BasicWithIncidentUrgencyRules(t *testing.T) {
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "acknowledgement_timeout", "1800"),
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "alert_creation", "create_incidents"),
"pagerduty_service.foo", "alert_creation", "create_alerts_and_incidents"),
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "incident_urgency_rule.#", "1"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -897,7 +897,7 @@ func TestAccPagerDutyService_BasicWithIncidentUrgencyRules(t *testing.T) {
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "acknowledgement_timeout", "3600"),
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "alert_creation", "create_incidents"),
"pagerduty_service.foo", "alert_creation", "create_alerts_and_incidents"),
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "incident_urgency_rule.#", "1"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -977,7 +977,7 @@ func TestAccPagerDutyService_FromBasicToCustomIncidentUrgencyRules(t *testing.T)
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "acknowledgement_timeout", "1800"),
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "alert_creation", "create_incidents"),
"pagerduty_service.foo", "alert_creation", "create_alerts_and_incidents"),
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "incident_urgency_rule.#", "1"),
resource.TestCheckResourceAttr(
Expand All @@ -999,7 +999,7 @@ func TestAccPagerDutyService_FromBasicToCustomIncidentUrgencyRules(t *testing.T)
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "acknowledgement_timeout", "3600"),
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "alert_creation", "create_incidents"),
"pagerduty_service.foo", "alert_creation", "create_alerts_and_incidents"),
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "incident_urgency_rule.#", "1"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -1120,7 +1120,7 @@ func TestAccPagerDutyService_ResponsePlay(t *testing.T) {
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "acknowledgement_timeout", "1800"),
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "alert_creation", "create_incidents"),
"pagerduty_service.foo", "alert_creation", "create_alerts_and_incidents"),
resource.TestCheckNoResourceAttr(
"pagerduty_service.foo", "alert_grouping"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -1160,7 +1160,7 @@ func TestAccPagerDutyService_ResponsePlay(t *testing.T) {
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "acknowledgement_timeout", "1800"),
resource.TestCheckResourceAttr(
"pagerduty_service.foo", "alert_creation", "create_incidents"),
"pagerduty_service.foo", "alert_creation", "create_alerts_and_incidents"),
resource.TestCheckNoResourceAttr(
"pagerduty_service.foo", "alert_grouping"),
resource.TestCheckResourceAttr(
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ The following arguments are supported:
* `acknowledgement_timeout` - (Optional) Time in seconds that an incident changes to the Triggered State after being Acknowledged. Disabled if set to the `"null"` string. If not passed in, will default to '"1800"'.
* `escalation_policy` - (Required) The escalation policy used by this service.
* `response_play` - (Optional) The response play used by this service.
* `alert_creation` - (Optional) Must be one of two values. PagerDuty receives events from your monitoring systems and can then create incidents in different ways. Value "create_incidents" is default: events will create an incident that cannot be merged. Value "create_alerts_and_incidents" is the alternative: events will create an alert and then add it to a new incident, these incidents can be merged. This option is recommended.
* `alert_creation` - (Optional) (Deprecated) The value "create_alerts_and_incidents" is being enforced in the state and this argument might be removed or become computed in next Major release. Please remove the use of this attribute as all services are going to be migrated to use alerts and incidents and will no longer be available in an upcoming major version. See [knowledge base](https://support.pagerduty.com/docs/alerts#enable-and-disable-alerts-on-a-service.) for details. Must be one of two values. PagerDuty receives events from your monitoring systems and can then create incidents in different ways. Value "create_incidents" is default: events will create an incident that cannot be merged. Value "create_alerts_and_incidents" is the alternative: events will create an alert and then add it to a new incident, these incidents can be merged. This option is recommended.
* `alert_grouping` - (Optional) (Deprecated) Defines how alerts on this service will be automatically grouped into incidents. Note that the alert grouping features are available only on certain plans. If not set, each alert will create a separate incident; If value is set to `time`: All alerts within a specified duration will be grouped into the same incident. This duration is set in the `alert_grouping_timeout` setting (described below). Available on Standard, Enterprise, and Event Intelligence plans; If value is set to `intelligent` - Alerts will be intelligently grouped based on a machine learning model that looks at the alert summary, timing, and the history of grouped alerts. Available on Enterprise and Event Intelligence plan. This field is deprecated, use `alert_grouping_parameters.type` instead,
* `alert_grouping_timeout` - (Optional) (Deprecated) The duration in minutes within which to automatically group incoming alerts. This setting applies only when `alert_grouping` is set to `time`. To continue grouping alerts until the incident is resolved, set this value to `0`. This field is deprecated, use `alert_grouping_parameters.config.timeout` instead,
* `alert_grouping_parameters` - (Optional) Defines how alerts on this service will be automatically grouped into incidents. Note that the alert grouping features are available only on certain plans. If not set, each alert will create a separate incident.
Expand Down
Loading