diff --git a/CHANGELOG.md b/CHANGELOG.md index 704e1a97e..c07160d9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/pagerduty/data_source_pagerduty_service_test.go b/pagerduty/data_source_pagerduty_service_test.go index cefdf1985..c5234ceee 100644 --- a/pagerduty/data_source_pagerduty_service_test.go +++ b/pagerduty/data_source_pagerduty_service_test.go @@ -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" { @@ -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 @@ -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" { diff --git a/pagerduty/resource_pagerduty_service.go b/pagerduty/resource_pagerduty_service.go index 586de1917..41b51a073 100644 --- a/pagerduty/resource_pagerduty_service.go +++ b/pagerduty/resource_pagerduty_service.go @@ -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", diff --git a/pagerduty/resource_pagerduty_service_test.go b/pagerduty/resource_pagerduty_service_test.go index b62f653d9..6f364e27d 100644 --- a/pagerduty/resource_pagerduty_service_test.go +++ b/pagerduty/resource_pagerduty_service_test.go @@ -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( @@ -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( @@ -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( @@ -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( @@ -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( @@ -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( @@ -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( @@ -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( @@ -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( @@ -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) } @@ -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) } @@ -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) } @@ -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) } @@ -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) } @@ -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) } @@ -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) } @@ -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) } @@ -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) } @@ -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) } diff --git a/website/docs/r/service.html.markdown b/website/docs/r/service.html.markdown index ef43fa469..3f6faac91 100644 --- a/website/docs/r/service.html.markdown +++ b/website/docs/r/service.html.markdown @@ -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.