UNPKG

@pulumi/pagerduty

Version:

A Pulumi package for creating and managing pagerduty cloud resources.

158 lines 6.79 kB
"use strict"; // *** 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.EventOrchestrationServiceCacheVariable = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * A [Cache Variable](https://support.pagerduty.com/docs/event-orchestration-variables) can be created on a Service Event Orchestration, in order to temporarily store event data to be referenced later within the Service Event Orchestration * * ## Example of configuring a Cache Variable for a Service Event Orchestration * * This example shows creating a service `Event Orchestration` and a `Cache Variable`. This Cache Variable will count and store the number of trigger events with 'database' in its title. Then all alerts sent to this Event Orchestration will have its severity upped to 'critical' if the count has reached at least 5 triggers within the last 1 minute. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pagerduty from "@pulumi/pagerduty"; * * const databaseTeam = new pagerduty.Team("database_team", {name: "Database Team"}); * const user1 = new pagerduty.User("user_1", { * name: "Earline Greenholt", * email: "125.greenholt.earline@graham.name", * teams: [databaseTeam.id], * }); * const dbEp = new pagerduty.EscalationPolicy("db_ep", { * name: "Database Escalation Policy", * numLoops: 2, * rules: [{ * escalationDelayInMinutes: 10, * targets: [{ * type: "user", * id: user1.id, * }], * }], * }); * const svc = new pagerduty.Service("svc", { * name: "My Database Service", * autoResolveTimeout: "14400", * acknowledgementTimeout: "600", * escalationPolicy: dbEp.id, * alertCreation: "create_alerts_and_incidents", * }); * const numDbTriggers = new pagerduty.EventOrchestrationServiceCacheVariable("num_db_triggers", { * service: svc.id, * name: "num_db_triggers", * conditions: [{ * expression: "event.summary matches part 'database'", * }], * configuration: { * type: "trigger_event_count", * ttlSeconds: 60, * }, * }); * const isMaintenance = new pagerduty.EventOrchestrationServiceCacheVariable("is_maintenance", { * service: svc.id, * name: "is_maintenance", * configuration: { * type: "external_data", * dataType: "boolean", * ttlSeconds: 7200, * }, * }); * const eventOrchestration = new pagerduty.EventOrchestrationService("event_orchestration", { * service: svc.id, * enableEventOrchestrationForService: true, * sets: [{ * id: "start", * rules: [ * { * label: "Suppress alerts if the service is in maintenance", * conditions: [{ * expression: "cache_var.is_maintenance == true", * }], * actions: { * suppress: true, * }, * }, * { * label: "Set severity to critical if we see at least 5 triggers on the DB within the last 1 minute", * conditions: [{ * expression: "cache_var.num_db_triggers >= 5", * }], * actions: { * severity: "critical", * }, * }, * ], * }], * catchAll: { * actions: {}, * }, * }); * ``` * * ## Import * * Cache Variables can be imported using colon-separated IDs, which is the combination of the Service Event Orchestration ID followed by the Cache Variable ID, e.g. * * ```sh * $ pulumi import pagerduty:index/eventOrchestrationServiceCacheVariable:EventOrchestrationServiceCacheVariable cache_variable PLBP09X:138ed254-3444-44ad-8cc7-701d69def439 * ``` */ class EventOrchestrationServiceCacheVariable extends pulumi.CustomResource { /** * Get an existing EventOrchestrationServiceCacheVariable 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 EventOrchestrationServiceCacheVariable(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of EventOrchestrationServiceCacheVariable. 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'] === EventOrchestrationServiceCacheVariable.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["conditions"] = state?.conditions; resourceInputs["configuration"] = state?.configuration; resourceInputs["disabled"] = state?.disabled; resourceInputs["name"] = state?.name; resourceInputs["service"] = state?.service; } else { const args = argsOrState; if (args?.configuration === undefined && !opts.urn) { throw new Error("Missing required property 'configuration'"); } if (args?.service === undefined && !opts.urn) { throw new Error("Missing required property 'service'"); } resourceInputs["conditions"] = args?.conditions; resourceInputs["configuration"] = args?.configuration; resourceInputs["disabled"] = args?.disabled; resourceInputs["name"] = args?.name; resourceInputs["service"] = args?.service; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(EventOrchestrationServiceCacheVariable.__pulumiType, name, resourceInputs, opts); } } exports.EventOrchestrationServiceCacheVariable = EventOrchestrationServiceCacheVariable; /** @internal */ EventOrchestrationServiceCacheVariable.__pulumiType = 'pagerduty:index/eventOrchestrationServiceCacheVariable:EventOrchestrationServiceCacheVariable'; //# sourceMappingURL=eventOrchestrationServiceCacheVariable.js.map