UNPKG

@pulumi/pagerduty

Version:

A Pulumi package for creating and managing pagerduty cloud resources.

306 lines 12.5 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "./types/input"; import * as outputs from "./types/output"; /** * A [v3 schedule](https://developer.pagerduty.com/api-reference/d90c4c94e3ce2-create-a-schedule) determines the time periods that users are on call using flexible rotation configurations. This resource uses the PagerDuty v3 Schedules API, which supports per-event assignment strategies and RFC 5545 recurrence rules. * * ## Schedule versions and resource naming * * The Terraform resource names do not line up one-to-one with the API version numbers, which is a common source of confusion. The table below maps the two: * * | Schedule type | Terraform resource | API version | * | -------------------- | ---------------------- | ---------------------- | * | Legacy schedule | `pagerduty.Schedule` | v2 (Accept header) | * | Shift-based schedule | `pagerduty.Schedulev2` | v3 (in the URL path) | * * `pagerduty.Schedule` manages the legacy schedule (now deprecated); `pagerduty.Schedulev2` manages the newer shift-based schedule. In the UI, legacy schedules are marked with a `legacy` tag on the schedules list page. * * ## Example Usage * * ### Rotating member assignment * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pagerduty from "@pulumi/pagerduty"; * * const example = new pagerduty.User("example", { * name: "Earline Greenholt", * email: "earline@example.com", * }); * const exampleSchedulev2 = new pagerduty.Schedulev2("example", { * name: "Engineering On-Call", * timeZone: "America/New_York", * description: "Managed by Pulumi", * rotations: [{ * events: [{ * name: "Weekday Business Hours", * startTime: "2026-06-01T09:00:00Z", * endTime: "2026-06-01T17:00:00Z", * effectiveSince: "2026-06-01T09:00:00Z", * recurrences: ["RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR"], * assignmentStrategies: [{ * type: "rotating_member_assignment_strategy", * shiftsPerMember: 1, * members: [{ * type: "user_member", * userId: example.id, * }], * }], * }], * }], * }); * ``` * * ### Every-member assignment (all members on-call simultaneously) * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pagerduty from "@pulumi/pagerduty"; * * const primary = new pagerduty.User("primary", { * name: "Alice", * email: "alice@example.com", * }); * const secondary = new pagerduty.User("secondary", { * name: "Bob", * email: "bob@example.com", * }); * const allHands = new pagerduty.Schedulev2("all_hands", { * name: "Weekend All-Hands On-Call", * timeZone: "UTC", * rotations: [{ * events: [{ * name: "Weekend Coverage", * startTime: "2026-06-06T00:00:00Z", * endTime: "2026-06-07T23:59:00Z", * effectiveSince: "2026-06-06T00:00:00Z", * recurrences: ["RRULE:FREQ=WEEKLY;BYDAY=SA,SU"], * assignmentStrategies: [{ * type: "every_member_assignment_strategy", * members: [ * { * type: "user_member", * userId: primary.id, * }, * { * type: "user_member", * userId: secondary.id, * }, * ], * }], * }], * }], * }); * ``` * * ## Migrating from `pagerduty.Schedule` * * The legacy `pagerduty.Schedule` resource models on-call coverage with `layer` blocks (a list of `users` rotating on a fixed `rotationTurnLengthSeconds`, optionally constrained by `restriction` blocks). The shift-based `pagerduty.Schedulev2` resource models the same coverage with `rotation` → `event` blocks, where an `assignmentStrategy` decides how the listed `member`s cover each occurrence of an RFC 5545 `recurrence`. * * The most common legacy shape is a single layer with several users handing off once per week (a 24/7 weekly rotation) and one or more team associations. The example below shows that shape before and after migration. * * **Before** — legacy `pagerduty.Schedule` (single `OnCall` layer, six users, weekly handoff, two teams): * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pagerduty from "@pulumi/pagerduty"; * * const exampleOncall = new pagerduty.Schedule("example_oncall", { * name: "Example OnCall Schedule", * description: "A Example OnCall Schedule.", * timeZone: "Europe/Amsterdam", * layers: [{ * name: "OnCall", * start: "2024-06-24T00:00:00-00:00", * rotationVirtualStart: "2025-03-17T07:00:00+02:00", * rotationTurnLengthSeconds: 604800, * users: [ * user1.id, * user2.id, * user3.id, * user4.id, * user5.id, * user6.id, * ], * }], * teams: [ * k8sPlatform.id, * k8sOperational.id, * ], * }); * ``` * * **After** — equivalent `pagerduty.Schedulev2`: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pagerduty from "@pulumi/pagerduty"; * * const exampleOncall = new pagerduty.Schedulev2("example_oncall", { * name: "Example OnCall Schedule", * description: "A Example OnCall Schedule.", * timeZone: "Europe/Amsterdam", * teams: [ * k8sPlatform.id, * k8sOperational.id, * ], * rotations: [{ * events: [{ * name: "OnCall", * startTime: "2025-03-17T07:00:00+02:00", * endTime: "2025-03-24T07:00:00+02:00", * effectiveSince: "2025-03-17T07:00:00+02:00", * recurrences: ["RRULE:FREQ=WEEKLY"], * assignmentStrategies: [{ * type: "rotating_member_assignment_strategy", * shiftsPerMember: 1, * members: [ * { * type: "user_member", * userId: user1.id, * }, * { * type: "user_member", * userId: user2.id, * }, * { * type: "user_member", * userId: user3.id, * }, * { * type: "user_member", * userId: user4.id, * }, * { * type: "user_member", * userId: user5.id, * }, * { * type: "user_member", * userId: user6.id, * }, * ], * }], * }], * }], * }); * ``` * * Field mapping: * * | Legacy (`pagerduty.Schedule`) | Shift-based (`pagerduty.Schedulev2`) | * | ------------------------------------- | -------------------------------------------------------------------- | * | `layer` | `rotation` (one `rotation` per layer) | * | `layer.name` | `rotation.event.name` | * | `layer.users` | `assignment_strategy.member` (one `member` per user) | * | `layer.rotation_turn_length_seconds` | `event.start_time`/`endTime` window + `recurrence` (e.g. one week → 7-day window + `RRULE:FREQ=WEEKLY`) | * | `layer.rotation_virtual_start` | `event.start_time` / `effectiveSince` | * | `layer.restriction` | a narrower `event` window plus a `BYDAY`/`BYHOUR` `RRULE` | * | `teams` | `teams` (unchanged) | * * > **Note:** Multiple members rotate when `assignment_strategy.type` is `"rotatingMemberAssignmentStrategy"`; use `"everyMemberAssignmentStrategy"` when everyone should be on call simultaneously. To reproduce a legacy `restriction` (e.g. weekday business hours), narrow the `event` window and encode the days/hours in the `RRULE` — see the *Rotating member assignment* example above. * * ## Import * * Schedules can be imported using the schedule `id`, e.g. * * ```sh * $ pulumi import pagerduty:index/schedulev2:Schedulev2 example P1234AB * ``` */ export declare class Schedulev2 extends pulumi.CustomResource { /** * Get an existing Schedulev2 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: string, id: pulumi.Input<pulumi.ID>, state?: Schedulev2State, opts?: pulumi.CustomResourceOptions): Schedulev2; /** * Returns true if the given object is an instance of Schedulev2. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is Schedulev2; /** * A description of the schedule. Maximum 1024 characters. */ readonly description: pulumi.Output<string>; /** * The name of the schedule. Maximum 255 characters. */ readonly name: pulumi.Output<string>; /** * One or more rotation blocks. Rotations documented below. */ readonly rotations: pulumi.Output<outputs.Schedulev2Rotation[] | undefined>; /** * List of team IDs to associate with this schedule. */ readonly teams: pulumi.Output<string[] | undefined>; /** * The time zone of the schedule (IANA format, e.g. `America/New_York`). */ readonly timeZone: pulumi.Output<string>; /** * Create a Schedulev2 resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: Schedulev2Args, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering Schedulev2 resources. */ export interface Schedulev2State { /** * A description of the schedule. Maximum 1024 characters. */ description?: pulumi.Input<string | undefined>; /** * The name of the schedule. Maximum 255 characters. */ name?: pulumi.Input<string | undefined>; /** * One or more rotation blocks. Rotations documented below. */ rotations?: pulumi.Input<pulumi.Input<inputs.Schedulev2Rotation>[] | undefined>; /** * List of team IDs to associate with this schedule. */ teams?: pulumi.Input<pulumi.Input<string>[] | undefined>; /** * The time zone of the schedule (IANA format, e.g. `America/New_York`). */ timeZone?: pulumi.Input<string | undefined>; } /** * The set of arguments for constructing a Schedulev2 resource. */ export interface Schedulev2Args { /** * A description of the schedule. Maximum 1024 characters. */ description?: pulumi.Input<string | undefined>; /** * The name of the schedule. Maximum 255 characters. */ name?: pulumi.Input<string | undefined>; /** * One or more rotation blocks. Rotations documented below. */ rotations?: pulumi.Input<pulumi.Input<inputs.Schedulev2Rotation>[] | undefined>; /** * List of team IDs to associate with this schedule. */ teams?: pulumi.Input<pulumi.Input<string>[] | undefined>; /** * The time zone of the schedule (IANA format, e.g. `America/New_York`). */ timeZone: pulumi.Input<string>; } //# sourceMappingURL=schedulev2.d.ts.map