Skip to content

Commit

Permalink
Merge pull request #836 from syogeswaran/ING1822_alert_creation_depre…
Browse files Browse the repository at this point in the history
…cated

[ING-1822] Mark alert_creation as deprecated and hide diffs
  • Loading branch information
cjgajard authored Mar 18, 2024
2 parents 690ce6e + eea415c commit a63ae6d
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 60 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 3.10.0 (Mar 15, 2024)

IMPROVEMENTS:

* `resource/resource_pagerduty_service`: Remove default value and enable diff suppression to account for planned end-of-life of create_incidents option.

## 3.9.0 (Feb 26, 2024)

FEATURES:
Expand Down
40 changes: 18 additions & 22 deletions pagerduty/data_source_pagerduty_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ func testAccDataSourcePagerDutyService(src, n string) resource.TestCheckFunc {
func testAccDataSourcePagerDutyServiceConfig(username, email, service, escalationPolicy, teamname string) string {
return fmt.Sprintf(`
resource "pagerduty_team" "team_one" {
name = "%s"
description = "team_one"
name = "%s"
description = "team_one"
}
resource "pagerduty_user" "test" {
Expand All @@ -111,24 +111,23 @@ resource "pagerduty_user" "test" {
}
resource "pagerduty_team_membership" "team_membership_one" {
team_id = pagerduty_team.team_one.id
user_id = pagerduty_user.test.id
team_id = pagerduty_team.team_one.id
user_id = pagerduty_user.test.id
}
resource "pagerduty_escalation_policy" "no_team_ep" {
name = "no_team_ep"
num_loops = 2
rule {
escalation_delay_in_minutes = 10
target {
type = "user_reference"
id = pagerduty_user.test.id
}
}
name = "no_team_ep"
num_loops = 2
rule {
escalation_delay_in_minutes = 10
target {
type = "user_reference"
id = pagerduty_user.test.id
}
}
}
resource "pagerduty_escalation_policy" "one_team_ep" {
depends_on = [pagerduty_team_membership.team_membership_one]
name = "%s"
num_loops = 2
Expand All @@ -143,24 +142,21 @@ resource "pagerduty_escalation_policy" "one_team_ep" {
}
resource "pagerduty_service" "no_team_service" {
name = "no_team_service"
auto_resolve_timeout = 14400
acknowledgement_timeout = 600
escalation_policy = pagerduty_escalation_policy.no_team_ep.id
alert_creation = "create_incidents"
name = "no_team_service"
auto_resolve_timeout = 14400
acknowledgement_timeout = 600
escalation_policy = pagerduty_escalation_policy.no_team_ep.id
}
resource "pagerduty_service" "one_team_service" {
name = "%s"
auto_resolve_timeout = 14400
acknowledgement_timeout = 600
escalation_policy = pagerduty_escalation_policy.one_team_ep.id
alert_creation = "create_incidents"
}
data "pagerduty_service" "no_team_service" {
name = pagerduty_service.no_team_service.name
name = pagerduty_service.no_team_service.name
}
data "pagerduty_service" "one_team_service" {
Expand Down
5 changes: 4 additions & 1 deletion pagerduty/resource_pagerduty_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ func resourcePagerDutyService() *schema.Resource {
"alert_creation": {
Type: schema.TypeString,
Optional: true,
Default: "create_incidents",
DiffSuppressFunc: func(k, oldValue, newValue string, d *schema.ResourceData) bool {
// Once migrated, alert_creation arguments previously defined as create_incidents would have been reported diffs for all matching services. As this is no longer configurable, opt to suppress this diff.
return true
},
ValidateDiagFunc: validateValueDiagFunc([]string{
"create_alerts_and_incidents",
"create_incidents",
Expand Down
69 changes: 33 additions & 36 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 Expand Up @@ -1308,7 +1308,6 @@ resource "pagerduty_service" "foo" {
auto_resolve_timeout = 1800
acknowledgement_timeout = 1800
escalation_policy = pagerduty_escalation_policy.foo.id
alert_creation = "create_incidents"
}
`, username, email, escalationPolicy, service)
}
Expand Down Expand Up @@ -1617,11 +1616,11 @@ resource "pagerduty_service" "foo" {
escalation_policy = pagerduty_escalation_policy.foo.id
alert_creation = "create_alerts_and_incidents"
alert_grouping_parameters {
type = "time"
config {
timeout = 0
}
}
type = "time"
config {
timeout = 0
}
}
}
`, username, email, escalationPolicy, service)
}
Expand Down Expand Up @@ -1695,12 +1694,12 @@ resource "pagerduty_service" "foo" {
escalation_policy = pagerduty_escalation_policy.foo.id
alert_creation = "create_alerts_and_incidents"
alert_grouping_parameters {
type = "intelligent"
config {
fields = null
timeout = 0
}
}
type = "intelligent"
config {
fields = null
timeout = 0
}
}
}
`, username, email, escalationPolicy, service)
}
Expand Down Expand Up @@ -1737,9 +1736,9 @@ resource "pagerduty_service" "foo" {
escalation_policy = pagerduty_escalation_policy.foo.id
alert_creation = "create_alerts_and_incidents"
alert_grouping_parameters {
type = "intelligent"
config {}
}
type = "intelligent"
config {}
}
}
`, username, email, escalationPolicy, service)
}
Expand Down Expand Up @@ -1776,8 +1775,8 @@ resource "pagerduty_service" "foo" {
escalation_policy = pagerduty_escalation_policy.foo.id
alert_creation = "create_alerts_and_incidents"
alert_grouping_parameters {
type = "intelligent"
}
type = "intelligent"
}
}
`, username, email, escalationPolicy, service)
}
Expand Down Expand Up @@ -1814,9 +1813,9 @@ resource "pagerduty_service" "foo" {
escalation_policy = pagerduty_escalation_policy.foo.id
alert_creation = "create_alerts_and_incidents"
alert_grouping_parameters {
type = null
config {}
}
type = null
config {}
}
}
`, username, email, escalationPolicy, service)
}
Expand Down Expand Up @@ -1853,9 +1852,9 @@ resource "pagerduty_service" "foo" {
escalation_policy = pagerduty_escalation_policy.foo.id
alert_creation = "create_alerts_and_incidents"
auto_pause_notifications_parameters {
enabled = true
enabled = true
timeout = 300
}
}
}
`, username, email, escalationPolicy, service)
}
Expand Down Expand Up @@ -1892,9 +1891,9 @@ resource "pagerduty_service" "foo" {
escalation_policy = pagerduty_escalation_policy.foo.id
alert_creation = "create_alerts_and_incidents"
auto_pause_notifications_parameters {
enabled = false
timeout = null
}
enabled = false
timeout = null
}
}
`, username, email, escalationPolicy, service)
}
Expand Down Expand Up @@ -2353,7 +2352,6 @@ resource "pagerduty_service" "foo" {
acknowledgement_timeout = 1800
escalation_policy = pagerduty_escalation_policy.foo.id
response_play = pagerduty_response_play.foo.id
alert_creation = "create_incidents"
}
`, username, email, escalationPolicy, responsePlay, service)
}
Expand Down Expand Up @@ -2406,7 +2404,6 @@ resource "pagerduty_service" "foo" {
acknowledgement_timeout = 1800
escalation_policy = pagerduty_escalation_policy.foo.id
response_play = null
alert_creation = "create_incidents"
}
`, username, email, escalationPolicy, responsePlay, service)
}
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) This attribute has been deprecated as all services will be migrated to use alerts and incidents. The incident only service setting will be no longer available and this attribute will be removed in an upcoming version. See knowledge base for details https://support.pagerduty.com/docs/alerts#enable-and-disable-alerts-on-a-service.
* `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

0 comments on commit a63ae6d

Please sign in to comment.