-
Notifications
You must be signed in to change notification settings - Fork 212
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
Event Orchestration: add support for Dynamic Routing and Dynamic Escalation Policy Assignment #885
Event Orchestration: add support for Dynamic Routing and Dynamic Escalation Policy Assignment #885
Conversation
@@ -374,6 +378,7 @@ func expandGlobalPathActions(v interface{}) *pagerduty.EventOrchestrationPathRul | |||
actions.Suppress = a["suppress"].(bool) | |||
actions.Suspend = intTypeToIntPtr(a["suspend"].(int)) | |||
actions.Priority = a["priority"].(string) | |||
actions.EscalationPolicy = stringTypeToStringPtr(a["escalation_policy"].(string)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotation: The EscalationPolicy
property is a string pointer (*string
) and not a string because we need to be able to send null
to the API in order to reset the action.
@@ -113,6 +135,54 @@ func resourcePagerDutyEventOrchestrationPathRouter() *schema.Resource { | |||
} | |||
} | |||
|
|||
func checkDynamicRoutingRule(context context.Context, diff *schema.ResourceDiff, i interface{}) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotation: This function performs the following checks and returns a plan error if any of the checks are violated:
- A Router can have at most one Dynamic Routing rule
- Dynamic Routing rule must be the first rule of the first ("start") set
- A Dynamic Routing rule, if placed correctly as the first rule of the first set, cannot have conditions and the route_to action
dra := am["dynamic_route_to"] | ||
if isNonEmptyList(dra) { | ||
actions.DynamicRouteTo = expandRouterDynamicRouteToAction(dra) | ||
} else { | ||
actions.RouteTo = am["route_to"].(string) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotation: Because dynamic_route_to
and route_to
are mutually-exclusive, we only set the route_to
action if dynamic_route_to
is not set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotation: Made the same changes as in the pagerduty/resource_pagerduty_event_orchestration_path_global.go
file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @alenapan this Event Orchestration API enhancement looks pretty good implemented for me.
nit: I'd only suggest you to consider the addition of this acceptance test, in order to test that imports for pagerduty_event_orchestration_router
keep working after adding dynamic_route_to
.
* Update the router example to use the pagerduty_service data source * Add a dynamic router rule example * Document the dynamic vs static router actions
…d Service Event Orchestration resources (#5) * WIP * Add tests for global and service orchs * Changes from review * Formatting changes, renamed methods to be clearer * Syntax errors 🤦 * Missed re-adding the expand line :o * * Catch-all supports EP, ensure it fits there * Add test cases to test tf resource * Add delete config * Do not add empty string for policy * Global and service path flattening * WIP Test for EP with terraformed ID * WIP * Temporary, running pagerduty-go from fork * Fixup tests, validate that *string escalation_policy is accepted * reformat test config * reimport go-pagerduty --------- Co-authored-by: Alena Pantuzenko <apantuzenko@pagerduty.com>
80bcc9e
to
9539e47
Compare
Hello @alenapan Documentation for dynamic_routing has a small error. actions {
dynamic_route_to { # no equal sign
lookup_by = "service_id"
source = "event.custom_details.pd_service_id"
regex = "(.*)" # regex instead of regexp
}
} |
Hi @NargiT, thanks for letting me know! I fixed it in #917 and passed it onto the TF Provider repo owners, so hopefully we can release it soon. |
Context
This PR adds support for Dynamic Routing and Dynamic Escalation Policy Assignment to the following resources:
pagerduty_event_orchestration_global
(Dynamic Escalation Policy Assignment)pagerduty_event_orchestration_router
(Dynamic Routing)pagerduty_event_orchestration_service
(Dynamic Escalation Policy Assignment)Testing
Testing conducted in individual PRs:
dynamic_route_to
action topagerduty_event_orchestration_router
alenapan/terraform-provider-pagerduty#1pagerduty_event_orchestration_router
alenapan/terraform-provider-pagerduty#2dynamic_route_to
action alenapan/terraform-provider-pagerduty#3escalation_policy
action alenapan/terraform-provider-pagerduty#4