Skip to content

Commit 50c2c13

Browse files
authoredFeb 26, 2024··
Merge pull request #749 from swbradshaw/ORCA-4263
[ORCA-4263] Support for incident custom fields for Event Orchestration
2 parents 620f5d2 + 145834d commit 50c2c13

11 files changed

+151
-44
lines changed
 

‎go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/hashicorp/terraform-plugin-mux v0.13.0
1616
github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0
1717
github.com/hashicorp/terraform-plugin-testing v1.6.0
18-
github.com/heimweh/go-pagerduty v0.0.0-20240206151700-a2cbd995ef76
18+
github.com/heimweh/go-pagerduty v0.0.0-20240226201314-bfc8dce0a3ff
1919
)
2020

2121
require (

‎go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S
9393
github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc=
9494
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
9595
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
96-
github.com/heimweh/go-pagerduty v0.0.0-20240206151700-a2cbd995ef76 h1:+JY7wpGAsTe/r51/nTdo3pQQ2Wj4cTXpsQfij1JK2gc=
97-
github.com/heimweh/go-pagerduty v0.0.0-20240206151700-a2cbd995ef76/go.mod h1:r59w5iyN01Qvi734yA5hZldbSeJJmsJzee/1kQ/MK7s=
96+
github.com/heimweh/go-pagerduty v0.0.0-20240226201314-bfc8dce0a3ff h1:w5M1cWVKdfMoQnSyzmLYFSpByn7cnC86vKZTiCBPiwY=
97+
github.com/heimweh/go-pagerduty v0.0.0-20240226201314-bfc8dce0a3ff/go.mod h1:r59w5iyN01Qvi734yA5hZldbSeJJmsJzee/1kQ/MK7s=
9898
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
9999
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
100100
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=

‎pagerduty/event_orchestration_path_util.go

+40
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ var eventOrchestrationAutomationActionObjectSchema = map[string]*schema.Schema{
6565
},
6666
}
6767

68+
var eventOrchestrationIncidentCustomFieldsObjectSchema = map[string]*schema.Schema{
69+
"id": {
70+
Type: schema.TypeString,
71+
Required: true,
72+
},
73+
"value": {
74+
Type: schema.TypeString,
75+
Required: true,
76+
},
77+
}
78+
6879
var eventOrchestrationAutomationActionSchema = map[string]*schema.Schema{
6980
"name": {
7081
Type: schema.TypeString,
@@ -235,6 +246,20 @@ func flattenEventOrchestrationPathVariables(v []*pagerduty.EventOrchestrationPat
235246
return res
236247
}
237248

249+
func expandEventOrchestrationPathIncidentCustomFields(v interface{}) []*pagerduty.EventOrchestrationPathIncidentCustomFieldUpdate {
250+
res := []*pagerduty.EventOrchestrationPathIncidentCustomFieldUpdate{}
251+
252+
for _, eai := range v.([]interface{}) {
253+
ea := eai.(map[string]interface{})
254+
ext := &pagerduty.EventOrchestrationPathIncidentCustomFieldUpdate{
255+
ID: ea["id"].(string),
256+
Value: ea["value"].(string),
257+
}
258+
res = append(res, ext)
259+
}
260+
return res
261+
}
262+
238263
func expandEventOrchestrationPathExtractions(v interface{}) []*pagerduty.EventOrchestrationPathActionExtractions {
239264
res := []*pagerduty.EventOrchestrationPathActionExtractions{}
240265

@@ -301,6 +326,21 @@ func expandEventOrchestrationAutomationActionObjects(v interface{}) []*pagerduty
301326
return result
302327
}
303328

329+
func flattenEventOrchestrationIncidentCustomFieldUpdates(v []*pagerduty.EventOrchestrationPathIncidentCustomFieldUpdate) []interface{} {
330+
var result []interface{}
331+
332+
for _, i := range v {
333+
custom_field := map[string]string{
334+
"id": i.ID,
335+
"value": i.Value,
336+
}
337+
338+
result = append(result, custom_field)
339+
}
340+
341+
return result
342+
}
343+
304344
func flattenEventOrchestrationAutomationActions(v []*pagerduty.EventOrchestrationPathAutomationAction) []interface{} {
305345
var result []interface{}
306346

‎pagerduty/resource_pagerduty_event_orchestration_path_global.go

+16-4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ var eventOrchestrationPathGlobalCatchAllActionsSchema = map[string]*schema.Schem
6565
Schema: eventOrchestrationPathExtractionsSchema,
6666
},
6767
},
68+
"incident_custom_field_update": {
69+
Type: schema.TypeList,
70+
Optional: true,
71+
Elem: &schema.Resource{
72+
Schema: eventOrchestrationIncidentCustomFieldsObjectSchema,
73+
},
74+
},
6875
}
6976

7077
var eventOrchestrationPathGlobalRuleActionsSchema = buildEventOrchestrationPathGlobalRuleActionsSchema()
@@ -349,10 +356,11 @@ func expandGlobalPathCatchAll(v interface{}) *pagerduty.EventOrchestrationPathCa
349356
}
350357

351358
func expandGlobalPathActions(v interface{}) *pagerduty.EventOrchestrationPathRuleActions {
352-
actions := &pagerduty.EventOrchestrationPathRuleActions{
353-
AutomationActions: []*pagerduty.EventOrchestrationPathAutomationAction{},
354-
Variables: []*pagerduty.EventOrchestrationPathActionVariables{},
355-
Extractions: []*pagerduty.EventOrchestrationPathActionExtractions{},
359+
var actions = &pagerduty.EventOrchestrationPathRuleActions{
360+
AutomationActions: []*pagerduty.EventOrchestrationPathAutomationAction{},
361+
Variables: []*pagerduty.EventOrchestrationPathActionVariables{},
362+
Extractions: []*pagerduty.EventOrchestrationPathActionExtractions{},
363+
IncidentCustomFieldUpdates: []*pagerduty.EventOrchestrationPathIncidentCustomFieldUpdate{},
356364
}
357365

358366
for _, i := range v.([]interface{}) {
@@ -372,6 +380,7 @@ func expandGlobalPathActions(v interface{}) *pagerduty.EventOrchestrationPathRul
372380
actions.AutomationActions = expandEventOrchestrationPathAutomationActions(a["automation_action"])
373381
actions.Variables = expandEventOrchestrationPathVariables(a["variable"])
374382
actions.Extractions = expandEventOrchestrationPathExtractions(a["extraction"])
383+
actions.IncidentCustomFieldUpdates = expandEventOrchestrationPathIncidentCustomFields(a["incident_custom_field_update"])
375384
}
376385

377386
return actions
@@ -449,6 +458,9 @@ func flattenGlobalPathActions(actions *pagerduty.EventOrchestrationPathRuleActio
449458
if actions.AutomationActions != nil {
450459
flattenedAction["automation_action"] = flattenEventOrchestrationAutomationActions(actions.AutomationActions)
451460
}
461+
if actions.IncidentCustomFieldUpdates != nil {
462+
flattenedAction["incident_custom_field_update"] = flattenEventOrchestrationIncidentCustomFieldUpdates(actions.IncidentCustomFieldUpdates)
463+
}
452464

453465
actionsMap = append(actionsMap, flattenedAction)
454466

‎pagerduty/resource_pagerduty_event_orchestration_path_global_test.go

+23-15
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,17 @@ func testAccCheckPagerDutyEventOrchestrationPathGlobalAutomationActionsConfig(t,
295295
return fmt.Sprintf("%s%s", createBaseGlobalOrchConfig(t, ep, s, o),
296296
`resource "pagerduty_event_orchestration_global" "my_global_orch" {
297297
event_orchestration = pagerduty_event_orchestration.orch.id
298-
298+
299299
set {
300300
id = "start"
301301
rule {
302302
label = "rule 1"
303-
actions {
303+
actions {
304304
automation_action {
305305
name = "test"
306306
url = "https://test.com"
307307
auto_send = true
308-
308+
309309
header {
310310
key = "foo"
311311
value = "bar"
@@ -314,7 +314,7 @@ func testAccCheckPagerDutyEventOrchestrationPathGlobalAutomationActionsConfig(t,
314314
key = "baz"
315315
value = "buz"
316316
}
317-
317+
318318
parameter {
319319
key = "source"
320320
value = "orch"
@@ -363,16 +363,16 @@ func testAccCheckPagerDutyEventOrchestrationPathGlobalAutomationActionsParamsUpd
363363
return fmt.Sprintf("%s%s", createBaseGlobalOrchConfig(t, ep, s, o),
364364
`resource "pagerduty_event_orchestration_global" "my_global_orch" {
365365
event_orchestration = pagerduty_event_orchestration.orch.id
366-
366+
367367
set {
368368
id = "start"
369369
rule {
370370
label = "rule 1"
371-
actions {
371+
actions {
372372
automation_action {
373373
name = "test1"
374374
url = "https://test1.com"
375-
375+
376376
header {
377377
key = "foo1"
378378
value = "bar1"
@@ -412,12 +412,12 @@ func testAccCheckPagerDutyEventOrchestrationPathGlobalAutomationActionsParamsDel
412412
return fmt.Sprintf("%s%s", createBaseGlobalOrchConfig(t, ep, s, o),
413413
`resource "pagerduty_event_orchestration_global" "my_global_orch" {
414414
event_orchestration = pagerduty_event_orchestration.orch.id
415-
415+
416416
set {
417417
id = "start"
418418
rule {
419419
label = "rule 1"
420-
actions {
420+
actions {
421421
automation_action {
422422
name = "test"
423423
url = "https://test.com"
@@ -444,7 +444,7 @@ func testAccCheckPagerDutyEventOrchestrationPathGlobalInvalidExtractionsConfig(t
444444
createBaseGlobalOrchConfig(t, ep, s, o),
445445
fmt.Sprintf(`resource "pagerduty_event_orchestration_global" "my_global_orch" {
446446
event_orchestration = pagerduty_event_orchestration.orch.id
447-
447+
448448
set {
449449
id = "start"
450450
rule {
@@ -467,7 +467,7 @@ func testAccCheckPagerDutyEventOrchestrationPathGlobalAllActionsConfig(t, ep, s,
467467
return fmt.Sprintf("%s%s", createBaseGlobalOrchConfig(t, ep, s, o),
468468
`resource "pagerduty_event_orchestration_global" "my_global_orch" {
469469
event_orchestration = pagerduty_event_orchestration.orch.id
470-
470+
471471
set {
472472
id = "start"
473473
rule {
@@ -505,6 +505,10 @@ func testAccCheckPagerDutyEventOrchestrationPathGlobalAllActionsConfig(t, ep, s,
505505
source = "event.group"
506506
target = "event.custom_details.message"
507507
}
508+
incident_custom_field_update {
509+
id = "PIJ90N7"
510+
value = "foo"
511+
}
508512
}
509513
}
510514
rule {
@@ -574,7 +578,7 @@ func testAccCheckPagerDutyEventOrchestrationPathGlobalAllActionsUpdateConfig(t,
574578
return fmt.Sprintf("%s%s", createBaseGlobalOrchConfig(t, ep, s, o),
575579
`resource "pagerduty_event_orchestration_global" "my_global_orch" {
576580
event_orchestration = pagerduty_event_orchestration.orch.id
577-
581+
578582
set {
579583
id = "start"
580584
rule {
@@ -603,6 +607,10 @@ func testAccCheckPagerDutyEventOrchestrationPathGlobalAllActionsUpdateConfig(t,
603607
target = "event.custom_details.message_upd"
604608
template = "[UPD] High CPU usage on {{variables.hostname}}: {{variables.cpu_val}}"
605609
}
610+
incident_custom_field_update {
611+
id = "PIJ90N7"
612+
value = "bar"
613+
}
606614
}
607615
}
608616
rule {
@@ -666,7 +674,7 @@ func testAccCheckPagerDutyEventOrchestrationPathGlobalAllActionsUpdateConfig(t,
666674
path = "event.custom_details.updated_at"
667675
type = "regex"
668676
value = "UPD (.*)"
669-
}
677+
}
670678
extraction {
671679
regex = ".*"
672680
source = "event.custom_details.region_upd"
@@ -682,7 +690,7 @@ func testAccCheckPagerDutyEventOrchestrationPathGlobalAllActionsDeleteConfig(t,
682690
return fmt.Sprintf("%s%s", createBaseGlobalOrchConfig(t, ep, s, o),
683691
`resource "pagerduty_event_orchestration_global" "my_global_orch" {
684692
event_orchestration = pagerduty_event_orchestration.orch.id
685-
693+
686694
set {
687695
id = "start"
688696
rule {
@@ -719,7 +727,7 @@ func testAccCheckPagerDutyEventOrchestrationPathGlobalOneSetNoActionsConfig(t, e
719727
return fmt.Sprintf("%s%s", createBaseGlobalOrchConfig(t, ep, s, o),
720728
`resource "pagerduty_event_orchestration_global" "my_global_orch" {
721729
event_orchestration = pagerduty_event_orchestration.orch.id
722-
730+
723731
set {
724732
id = "start"
725733
rule {

‎pagerduty/resource_pagerduty_event_orchestration_path_service.go

+12
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ var eventOrchestrationPathServiceCatchAllActionsSchema = map[string]*schema.Sche
7575
Schema: eventOrchestrationPathExtractionsSchema,
7676
},
7777
},
78+
"incident_custom_field_update": {
79+
Type: schema.TypeList,
80+
Optional: true,
81+
Elem: &schema.Resource{
82+
Schema: eventOrchestrationIncidentCustomFieldsObjectSchema,
83+
},
84+
},
7885
}
7986

8087
var eventOrchestrationPathServiceRuleActionsSchema = buildEventOrchestrationPathServiceRuleActionsSchema()
@@ -456,6 +463,7 @@ func expandServicePathActions(v interface{}) *pagerduty.EventOrchestrationPathRu
456463
PagerdutyAutomationActions: []*pagerduty.EventOrchestrationPathPagerdutyAutomationAction{},
457464
Variables: []*pagerduty.EventOrchestrationPathActionVariables{},
458465
Extractions: []*pagerduty.EventOrchestrationPathActionExtractions{},
466+
IncidentCustomFieldUpdates: []*pagerduty.EventOrchestrationPathIncidentCustomFieldUpdate{},
459467
}
460468

461469
for _, i := range v.([]interface{}) {
@@ -475,6 +483,7 @@ func expandServicePathActions(v interface{}) *pagerduty.EventOrchestrationPathRu
475483
actions.AutomationActions = expandEventOrchestrationPathAutomationActions(a["automation_action"])
476484
actions.Variables = expandEventOrchestrationPathVariables(a["variable"])
477485
actions.Extractions = expandEventOrchestrationPathExtractions(a["extraction"])
486+
actions.IncidentCustomFieldUpdates = expandEventOrchestrationPathIncidentCustomFields(a["incident_custom_field_update"])
478487
}
479488

480489
return actions
@@ -569,6 +578,9 @@ func flattenServicePathActions(actions *pagerduty.EventOrchestrationPathRuleActi
569578
if actions.AutomationActions != nil {
570579
flattenedAction["automation_action"] = flattenEventOrchestrationAutomationActions(actions.AutomationActions)
571580
}
581+
if actions.IncidentCustomFieldUpdates != nil {
582+
flattenedAction["incident_custom_field_update"] = flattenEventOrchestrationIncidentCustomFieldUpdates(actions.IncidentCustomFieldUpdates)
583+
}
572584

573585
actionsMap = append(actionsMap, flattenedAction)
574586

‎pagerduty/resource_pagerduty_event_orchestration_path_service_test.go

+26-18
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ func testAccCheckPagerDutyEventOrchestrationPathServiceDefaultConfig(ep, s strin
345345
return fmt.Sprintf("%s%s", createBaseServicePathConfig(ep, s),
346346
`resource "pagerduty_event_orchestration_service" "serviceA" {
347347
service = pagerduty_service.bar.id
348-
348+
349349
set {
350350
id = "start"
351351
}
@@ -361,17 +361,17 @@ func testAccCheckPagerDutyEventOrchestrationPathServiceAutomationActionsConfig(e
361361
return fmt.Sprintf("%s%s", createBaseServicePathConfig(ep, s),
362362
`resource "pagerduty_event_orchestration_service" "serviceA" {
363363
service = pagerduty_service.bar.id
364-
364+
365365
set {
366366
id = "start"
367367
rule {
368368
label = "rule 1"
369-
actions {
369+
actions {
370370
automation_action {
371371
name = "test"
372372
url = "https://test.com"
373373
auto_send = true
374-
374+
375375
header {
376376
key = "foo"
377377
value = "bar"
@@ -380,7 +380,7 @@ func testAccCheckPagerDutyEventOrchestrationPathServiceAutomationActionsConfig(e
380380
key = "baz"
381381
value = "buz"
382382
}
383-
383+
384384
parameter {
385385
key = "source"
386386
value = "orch"
@@ -429,16 +429,16 @@ func testAccCheckPagerDutyEventOrchestrationPathServiceAutomationActionsParamsUp
429429
return fmt.Sprintf("%s%s", createBaseServicePathConfig(ep, s),
430430
`resource "pagerduty_event_orchestration_service" "serviceA" {
431431
service = pagerduty_service.bar.id
432-
432+
433433
set {
434434
id = "start"
435435
rule {
436436
label = "rule 1"
437-
actions {
437+
actions {
438438
automation_action {
439439
name = "test1"
440440
url = "https://test1.com"
441-
441+
442442
header {
443443
key = "foo1"
444444
value = "bar1"
@@ -478,12 +478,12 @@ func testAccCheckPagerDutyEventOrchestrationPathServiceAutomationActionsParamsDe
478478
return fmt.Sprintf("%s%s", createBaseServicePathConfig(ep, s),
479479
`resource "pagerduty_event_orchestration_service" "serviceA" {
480480
service = pagerduty_service.bar.id
481-
481+
482482
set {
483483
id = "start"
484484
rule {
485485
label = "rule 1"
486-
actions {
486+
actions {
487487
automation_action {
488488
name = "test"
489489
url = "https://test.com"
@@ -510,7 +510,7 @@ func testAccCheckPagerDutyEventOrchestrationPathServiceInvalidExtractionsConfig(
510510
createBaseServicePathConfig(ep, s),
511511
fmt.Sprintf(`resource "pagerduty_event_orchestration_service" "serviceA" {
512512
service = pagerduty_service.bar.id
513-
513+
514514
set {
515515
id = "start"
516516
rule {
@@ -533,7 +533,7 @@ func testAccCheckPagerDutyEventOrchestrationPathServiceAllActionsConfig(ep, s st
533533
return fmt.Sprintf("%s%s", createBaseServicePathConfig(ep, s),
534534
`resource "pagerduty_event_orchestration_service" "serviceA" {
535535
service = pagerduty_service.bar.id
536-
536+
537537
set {
538538
id = "start"
539539
rule {
@@ -574,6 +574,10 @@ func testAccCheckPagerDutyEventOrchestrationPathServiceAllActionsConfig(ep, s st
574574
source = "event.group"
575575
target = "event.custom_details.message"
576576
}
577+
incident_custom_field_update {
578+
id = "PIJ90N7"
579+
value = "foo"
580+
}
577581
}
578582
}
579583
}
@@ -637,7 +641,7 @@ func testAccCheckPagerDutyEventOrchestrationPathServiceAllActionsUpdateConfig(ep
637641
return fmt.Sprintf("%s%s", createBaseServicePathConfig(ep, s),
638642
`resource "pagerduty_event_orchestration_service" "serviceA" {
639643
service = pagerduty_service.bar.id
640-
644+
641645
set {
642646
id = "start"
643647
rule {
@@ -669,6 +673,10 @@ func testAccCheckPagerDutyEventOrchestrationPathServiceAllActionsUpdateConfig(ep
669673
target = "event.custom_details.message_upd"
670674
template = "[UPD] High CPU usage on {{variables.hostname}}: {{variables.cpu_val}}"
671675
}
676+
incident_custom_field_update {
677+
id = "PIJ90N7"
678+
value = "bar"
679+
}
672680
}
673681
}
674682
}
@@ -726,7 +734,7 @@ func testAccCheckPagerDutyEventOrchestrationPathServiceAllActionsUpdateConfig(ep
726734
path = "event.custom_details.updated_at"
727735
type = "regex"
728736
value = "UPD (.*)"
729-
}
737+
}
730738
extraction {
731739
regex = ".*"
732740
source = "event.custom_details.region_upd"
@@ -742,7 +750,7 @@ func testAccCheckPagerDutyEventOrchestrationPathServiceAllActionsDeleteConfig(ep
742750
return fmt.Sprintf("%s%s", createBaseServicePathConfig(ep, s),
743751
`resource "pagerduty_event_orchestration_service" "serviceA" {
744752
service = pagerduty_service.bar.id
745-
753+
746754
set {
747755
id = "start"
748756
rule {
@@ -775,7 +783,7 @@ func testAccCheckPagerDutyEventOrchestrationPathServiceOneSetNoActionsConfig(ep,
775783
return fmt.Sprintf("%s%s", createBaseServicePathConfig(ep, s),
776784
`resource "pagerduty_event_orchestration_service" "serviceA" {
777785
service = pagerduty_service.bar.id
778-
786+
779787
set {
780788
id = "start"
781789
rule {
@@ -800,7 +808,7 @@ func testAccCheckPagerDutyEventOrchestrationPathServiceEnableEOForServiceEnableU
800808
`resource "pagerduty_event_orchestration_service" "serviceA" {
801809
service = pagerduty_service.bar.id
802810
enable_event_orchestration_for_service = true
803-
811+
804812
set {
805813
id = "start"
806814
}
@@ -817,7 +825,7 @@ func testAccCheckPagerDutyEventOrchestrationPathServiceEnableEOForServiceDisable
817825
`resource "pagerduty_event_orchestration_service" "serviceA" {
818826
service = pagerduty_service.bar.id
819827
enable_event_orchestration_for_service = false
820-
828+
821829
set {
822830
id = "start"
823831
}

‎vendor/github.com/heimweh/go-pagerduty/pagerduty/event_orchestration_path.go

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vendor/modules.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ github.com/hashicorp/terraform-svchost
250250
# github.com/hashicorp/yamux v0.1.1
251251
## explicit; go 1.15
252252
github.com/hashicorp/yamux
253-
# github.com/heimweh/go-pagerduty v0.0.0-20240206151700-a2cbd995ef76
253+
# github.com/heimweh/go-pagerduty v0.0.0-20240226201314-bfc8dce0a3ff
254254
## explicit; go 1.17
255255
github.com/heimweh/go-pagerduty/pagerduty
256256
github.com/heimweh/go-pagerduty/persistentconfig

‎website/docs/r/event_orchestration_global.html.markdown

+3
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ The following arguments are supported:
113113
* `suspend` - (Optional) The number of seconds to suspend the resulting alert before triggering. This effectively pauses incident notifications. If a `resolve` event arrives before the alert triggers then PagerDuty won't create an incident for this alert.
114114
* `priority` - (Optional) The ID of the priority you want to set on resulting incident. Consider using the [`pagerduty_priority`](https://registry.terraform.io/providers/PagerDuty/pagerduty/latest/docs/data-sources/priority) data source.
115115
* `annotate` - (Optional) Add this text as a note on the resulting incident.
116+
* `incident_custom_field_update` - (Optional) Assign a custom field to the resulting incident.
117+
* `id` - (Required) The custom field id
118+
* `value` - (Required) The value to assign to this custom field
116119
* `automation_action` - (Optional) Create a [Webhook](https://support.pagerduty.com/docs/event-orchestration#webhooks) associated with the resulting incident.
117120
* `name` - (Required) Name of this Webhook.
118121
* `url` - (Required) The API endpoint where PagerDuty's servers will send the webhook request.

‎website/docs/r/event_orchestration_service.html.markdown

+21-3
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,22 @@ resource "pagerduty_team" "engineering" {
3131
resource "pagerduty_user" "example" {
3232
name = "Earline Greenholt"
3333
email = "125.greenholt.earline@graham.name"
34-
teams = [pagerduty_team.engineering.id]
3534
}
3635
37-
resource "pagerduty_escalation_policy" "foo" {
36+
resource "pagerduty_team_membership" "foo" {
37+
user_id = pagerduty_user.example.id
38+
team_id = pagerduty_team.engineering.id
39+
role = "manager"
40+
}
41+
42+
resource "pagerduty_escalation_policy" "example" {
3843
name = "Engineering Escalation Policy"
3944
num_loops = 2
4045
4146
rule {
4247
escalation_delay_in_minutes = 10
4348
target {
44-
type = "user"
49+
type = "user_reference"
4550
id = pagerduty_user.example.id
4651
}
4752
}
@@ -55,6 +60,12 @@ resource "pagerduty_service" "example" {
5560
alert_creation = "create_alerts_and_incidents"
5661
}
5762
63+
resource "pagerduty_incident_custom_field" "cs_impact" {
64+
name = "impact"
65+
data_type = "string"
66+
field_type = "single_value"
67+
}
68+
5869
data "pagerduty_priority" "p1" {
5970
name = "P1"
6071
}
@@ -99,6 +110,10 @@ resource "pagerduty_event_orchestration_service" "www" {
99110
actions {
100111
annotate = "Please use our P1 runbook: https://docs.test/p1-runbook"
101112
priority = data.pagerduty_priority.p1.id
113+
incident_custom_field_update {
114+
id = pagerduty_incident_custom_field.cs_impact.id
115+
value = "High Impact"
116+
}
102117
}
103118
}
104119
rule {
@@ -170,6 +185,9 @@ The following arguments are supported:
170185
* `suspend` - (Optional) The number of seconds to suspend the resulting alert before triggering. This effectively pauses incident notifications. If a `resolve` event arrives before the alert triggers then PagerDuty won't create an incident for this alert.
171186
* `priority` - (Optional) The ID of the priority you want to set on resulting incident. Consider using the [`pagerduty_priority`](https://registry.terraform.io/providers/PagerDuty/pagerduty/latest/docs/data-sources/priority) data source.
172187
* `annotate` - (Optional) Add this text as a note on the resulting incident.
188+
* `incident_custom_field_update` - (Optional) Assign a custom field to the resulting incident.
189+
* `id` - (Required) The custom field id
190+
* `value` - (Required) The value to assign to this custom field
173191
* `pagerduty_automation_action` - (Optional) Configure a [Process Automation](https://support.pagerduty.com/docs/event-orchestration#process-automation) associated with the resulting incident.
174192
* `action_id` - (Required) Id of the Process Automation action to be triggered.
175193
* `automation_action` - (Optional) Create a [Webhook](https://support.pagerduty.com/docs/event-orchestration#webhooks) associated with the resulting incident.

0 commit comments

Comments
 (0)
Please sign in to comment.