@pulumi/pagerduty
Version:
A Pulumi package for creating and managing pagerduty cloud resources.
236 lines • 11.2 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventOrchestrationService = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* A [Service Orchestration](https://support.pagerduty.com/docs/event-orchestration#service-orchestrations) allows you to create a set of Event Rules. The Service Orchestration evaluates Events sent to this Service against each of its rules, beginning with the rules in the "start" set. When a matching rule is found, it can modify and enhance the event and can route the event to another set of rules within this Service Orchestration for further processing.
*
* > If you have a Service that uses [Service Event Rules](https://support.pagerduty.com/docs/rulesets#service-event-rules), you can switch to [Service Orchestrations](https://support.pagerduty.com/docs/event-orchestration#service-orchestrations) at any time setting the attribute `enableEventOrchestrationForService` to `true`. Please read the [Switch to Service Orchestrations](https://support.pagerduty.com/docs/event-orchestration#switch-to-service-orchestrations) instructions for more information.
*
* ## Example of configuring a Service Orchestration
*
* This example shows creating `Team`, `User`, `Escalation Policy`, and `Service` resources followed by creating a Service Orchestration to handle Events sent to that Service.
*
* This example also shows using the pagerduty.getPriority and pagerduty.EscalationPolicy data sources to configure `priority` and `escalationPolicy` actions for a rule.
*
* This example shows a Service Orchestration that has nested sets: a rule in the "start" set has a `routeTo` action pointing at the "step-two" set.
*
* The `catchAll` actions will be applied if an Event reaches the end of any set without matching any rules in that set. In this example the `catchAll` doesn't have any `actions` so it'll leave events as-is.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pagerduty from "@pulumi/pagerduty";
*
* const engineering = new pagerduty.Team("engineering", {name: "Engineering"});
* const example = new pagerduty.User("example", {
* name: "Earline Greenholt",
* email: "125.greenholt.earline@graham.name",
* });
* const foo = new pagerduty.TeamMembership("foo", {
* userId: example.id,
* teamId: engineering.id,
* role: "manager",
* });
* const exampleEscalationPolicy = new pagerduty.EscalationPolicy("example", {
* name: "Engineering Escalation Policy",
* numLoops: 2,
* rules: [{
* escalationDelayInMinutes: 10,
* targets: [{
* type: "user_reference",
* id: example.id,
* }],
* }],
* });
* const exampleService = new pagerduty.Service("example", {
* name: "My Web App",
* autoResolveTimeout: "14400",
* acknowledgementTimeout: "600",
* escalationPolicy: exampleEscalationPolicy.id,
* alertCreation: "create_alerts_and_incidents",
* });
* const csImpact = new pagerduty.IncidentCustomField("cs_impact", {
* name: "impact",
* dataType: "string",
* fieldType: "single_value",
* });
* const p1 = pagerduty.getPriority({
* name: "P1",
* });
* const sreEscPolicy = pagerduty.getEscalationPolicy({
* name: "SRE Escalation Policy",
* });
* const www = new pagerduty.EventOrchestrationService("www", {
* service: exampleService.id,
* enableEventOrchestrationForService: true,
* sets: [
* {
* id: "start",
* rules: [{
* label: "Always apply some consistent event transformations to all events",
* actions: {
* variables: [{
* name: "hostname",
* path: "event.component",
* value: "hostname: (.*)",
* type: "regex",
* }],
* extractions: [
* {
* template: "{{variables.hostname}}",
* target: "event.custom_details.hostname",
* },
* {
* source: "event.source",
* regex: "www (.*) service",
* target: "event.source",
* },
* ],
* routeTo: "step-two",
* },
* }],
* },
* {
* id: "step-two",
* rules: [
* {
* label: "All critical alerts should be treated as P1 incident",
* conditions: [{
* expression: "event.severity matches 'critical'",
* }],
* actions: {
* annotate: "Please use our P1 runbook: https://docs.test/p1-runbook",
* priority: p1.then(p1 => p1.id),
* incidentCustomFieldUpdates: [{
* id: csImpact.id,
* value: "High Impact",
* }],
* },
* },
* {
* label: "If any of the API apps are unavailable, page the SRE team",
* conditions: [{
* expression: "event.custom_details.service_name matches part '-api' and event.custom_details.status_code matches '502'",
* }],
* actions: {
* escalationPolicy: sreEscPolicy.then(sreEscPolicy => sreEscPolicy.id),
* },
* },
* {
* label: "If there's something wrong on the canary let the team know about it in our deployments Slack channel",
* conditions: [{
* expression: "event.custom_details.hostname matches part 'canary'",
* }],
* actions: {
* automationAction: {
* name: "Canary Slack Notification",
* url: "https://our-slack-listerner.test/canary-notification",
* autoSend: true,
* triggerTypes: "alert_triggered",
* parameters: [
* {
* key: "channel",
* value: "#my-team-channel",
* },
* {
* key: "message",
* value: "something is wrong with the canary deployment",
* },
* ],
* headers: [{
* key: "X-Notification-Source",
* value: "PagerDuty Incident Webhook",
* }],
* },
* },
* },
* {
* label: "Never bother the on-call for info-level events outside of work hours, and let an Automation Action fix it instead",
* conditions: [{
* expression: "event.severity matches 'info' and not (now in Mon,Tue,Wed,Thu,Fri 09:00:00 to 17:00:00 America/Los_Angeles)",
* }],
* actions: {
* suppress: true,
* pagerdutyAutomationAction: {
* actionId: "01FJV5A8OA5MKHOYFHV35SM2Z0",
* triggerTypes: "alert_suppressed",
* },
* },
* },
* ],
* },
* ],
* catchAll: {
* actions: {},
* },
* });
* ```
*
* ## Import
*
* Service Orchestration can be imported using the `id` of the Service, e.g.
*
* ```sh
* $ pulumi import pagerduty:index/eventOrchestrationService:EventOrchestrationService service PFEODA7
* ```
*/
class EventOrchestrationService extends pulumi.CustomResource {
/**
* Get an existing EventOrchestrationService resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new EventOrchestrationService(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of EventOrchestrationService. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === EventOrchestrationService.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["catchAll"] = state?.catchAll;
resourceInputs["enableEventOrchestrationForService"] = state?.enableEventOrchestrationForService;
resourceInputs["service"] = state?.service;
resourceInputs["sets"] = state?.sets;
}
else {
const args = argsOrState;
if (args?.catchAll === undefined && !opts.urn) {
throw new Error("Missing required property 'catchAll'");
}
if (args?.service === undefined && !opts.urn) {
throw new Error("Missing required property 'service'");
}
if (args?.sets === undefined && !opts.urn) {
throw new Error("Missing required property 'sets'");
}
resourceInputs["catchAll"] = args?.catchAll;
resourceInputs["enableEventOrchestrationForService"] = args?.enableEventOrchestrationForService;
resourceInputs["service"] = args?.service;
resourceInputs["sets"] = args?.sets;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(EventOrchestrationService.__pulumiType, name, resourceInputs, opts);
}
}
exports.EventOrchestrationService = EventOrchestrationService;
/** @internal */
EventOrchestrationService.__pulumiType = 'pagerduty:index/eventOrchestrationService:EventOrchestrationService';
//# sourceMappingURL=eventOrchestrationService.js.map