UserNotificationRule

A notification rule configures where and when a PagerDuty user is notified when a triggered incident is assigned to him. Unique notification rules can be created for both high and low-urgency incidents.

Example Usage

using Pulumi;
using Pagerduty = Pulumi.Pagerduty;

class MyStack : Stack
{
    public MyStack()
    {
        var example = new Pagerduty.User("example", new Pagerduty.UserArgs
        {
            Email = "125.greenholt.earline@graham.name",
        });
        var email = new Pagerduty.UserContactMethod("email", new Pagerduty.UserContactMethodArgs
        {
            UserId = example.Id,
            Type = "email_contact_method",
            Address = "foo@bar.com",
            Label = "Work",
        });
        var phone = new Pagerduty.UserContactMethod("phone", new Pagerduty.UserContactMethodArgs
        {
            UserId = example.Id,
            Type = "phone_contact_method",
            CountryCode = 1,
            Address = "2025550199",
            Label = "Work",
        });
        var sms = new Pagerduty.UserContactMethod("sms", new Pagerduty.UserContactMethodArgs
        {
            UserId = example.Id,
            Type = "sms_contact_method",
            CountryCode = 1,
            Address = "2025550199",
            Label = "Work",
        });
        var highUrgencyPhone = new Pagerduty.UserNotificationRule("highUrgencyPhone", new Pagerduty.UserNotificationRuleArgs
        {
            UserId = example.Id,
            StartDelayInMinutes = 1,
            Urgency = "high",
            ContactMethod = new Pagerduty.Inputs.UserNotificationRuleContactMethodArgs
            {
                Type = "phone_contact_method",
                Id = phone.Id,
            },
        });
        var lowUrgencyEmail = new Pagerduty.UserNotificationRule("lowUrgencyEmail", new Pagerduty.UserNotificationRuleArgs
        {
            UserId = example.Id,
            StartDelayInMinutes = 1,
            Urgency = "low",
            ContactMethod = new Pagerduty.Inputs.UserNotificationRuleContactMethodArgs
            {
                Type = "email_contact_method",
                Id = email.Id,
            },
        });
        var lowUrgencySms = new Pagerduty.UserNotificationRule("lowUrgencySms", new Pagerduty.UserNotificationRuleArgs
        {
            UserId = example.Id,
            StartDelayInMinutes = 10,
            Urgency = "low",
            ContactMethod = new Pagerduty.Inputs.UserNotificationRuleContactMethodArgs
            {
                Type = "sms_contact_method",
                Id = sms.Id,
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-pagerduty/sdk/v2/go/pagerduty"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := pagerduty.NewUser(ctx, "example", &pagerduty.UserArgs{
			Email: pulumi.String("125.greenholt.earline@graham.name"),
		})
		if err != nil {
			return err
		}
		email, err := pagerduty.NewUserContactMethod(ctx, "email", &pagerduty.UserContactMethodArgs{
			UserId:  example.ID(),
			Type:    pulumi.String("email_contact_method"),
			Address: pulumi.String("foo@bar.com"),
			Label:   pulumi.String("Work"),
		})
		if err != nil {
			return err
		}
		phone, err := pagerduty.NewUserContactMethod(ctx, "phone", &pagerduty.UserContactMethodArgs{
			UserId:      example.ID(),
			Type:        pulumi.String("phone_contact_method"),
			CountryCode: pulumi.Int(1),
			Address:     pulumi.String("2025550199"),
			Label:       pulumi.String("Work"),
		})
		if err != nil {
			return err
		}
		sms, err := pagerduty.NewUserContactMethod(ctx, "sms", &pagerduty.UserContactMethodArgs{
			UserId:      example.ID(),
			Type:        pulumi.String("sms_contact_method"),
			CountryCode: pulumi.Int(1),
			Address:     pulumi.String("2025550199"),
			Label:       pulumi.String("Work"),
		})
		if err != nil {
			return err
		}
		_, err = pagerduty.NewUserNotificationRule(ctx, "highUrgencyPhone", &pagerduty.UserNotificationRuleArgs{
			UserId:              example.ID(),
			StartDelayInMinutes: pulumi.Int(1),
			Urgency:             pulumi.String("high"),
			ContactMethod: &pagerduty.UserNotificationRuleContactMethodArgs{
				Type: pulumi.String("phone_contact_method"),
				Id:   phone.ID(),
			},
		})
		if err != nil {
			return err
		}
		_, err = pagerduty.NewUserNotificationRule(ctx, "lowUrgencyEmail", &pagerduty.UserNotificationRuleArgs{
			UserId:              example.ID(),
			StartDelayInMinutes: pulumi.Int(1),
			Urgency:             pulumi.String("low"),
			ContactMethod: &pagerduty.UserNotificationRuleContactMethodArgs{
				Type: pulumi.String("email_contact_method"),
				Id:   email.ID(),
			},
		})
		if err != nil {
			return err
		}
		_, err = pagerduty.NewUserNotificationRule(ctx, "lowUrgencySms", &pagerduty.UserNotificationRuleArgs{
			UserId:              example.ID(),
			StartDelayInMinutes: pulumi.Int(10),
			Urgency:             pulumi.String("low"),
			ContactMethod: &pagerduty.UserNotificationRuleContactMethodArgs{
				Type: pulumi.String("sms_contact_method"),
				Id:   sms.ID(),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_pagerduty as pagerduty

example = pagerduty.User("example", email="125.greenholt.earline@graham.name")
email = pagerduty.UserContactMethod("email",
    user_id=example.id,
    type="email_contact_method",
    address="foo@bar.com",
    label="Work")
phone = pagerduty.UserContactMethod("phone",
    user_id=example.id,
    type="phone_contact_method",
    country_code=1,
    address="2025550199",
    label="Work")
sms = pagerduty.UserContactMethod("sms",
    user_id=example.id,
    type="sms_contact_method",
    country_code=1,
    address="2025550199",
    label="Work")
high_urgency_phone = pagerduty.UserNotificationRule("highUrgencyPhone",
    user_id=example.id,
    start_delay_in_minutes=1,
    urgency="high",
    contact_method=pagerduty.UserNotificationRuleContactMethodArgs(
        type="phone_contact_method",
        id=phone.id,
    ))
low_urgency_email = pagerduty.UserNotificationRule("lowUrgencyEmail",
    user_id=example.id,
    start_delay_in_minutes=1,
    urgency="low",
    contact_method=pagerduty.UserNotificationRuleContactMethodArgs(
        type="email_contact_method",
        id=email.id,
    ))
low_urgency_sms = pagerduty.UserNotificationRule("lowUrgencySms",
    user_id=example.id,
    start_delay_in_minutes=10,
    urgency="low",
    contact_method=pagerduty.UserNotificationRuleContactMethodArgs(
        type="sms_contact_method",
        id=sms.id,
    ))
import * as pulumi from "@pulumi/pulumi";
import * as pagerduty from "@pulumi/pagerduty";

const example = new pagerduty.User("example", {email: "125.greenholt.earline@graham.name"});
const email = new pagerduty.UserContactMethod("email", {
    userId: example.id,
    type: "email_contact_method",
    address: "foo@bar.com",
    label: "Work",
});
const phone = new pagerduty.UserContactMethod("phone", {
    userId: example.id,
    type: "phone_contact_method",
    countryCode: "+1",
    address: "2025550199",
    label: "Work",
});
const sms = new pagerduty.UserContactMethod("sms", {
    userId: example.id,
    type: "sms_contact_method",
    countryCode: "+1",
    address: "2025550199",
    label: "Work",
});
const highUrgencyPhone = new pagerduty.UserNotificationRule("highUrgencyPhone", {
    userId: example.id,
    startDelayInMinutes: 1,
    urgency: "high",
    contactMethod: {
        type: "phone_contact_method",
        id: phone.id,
    },
});
const lowUrgencyEmail = new pagerduty.UserNotificationRule("lowUrgencyEmail", {
    userId: example.id,
    startDelayInMinutes: 1,
    urgency: "low",
    contactMethod: {
        type: "email_contact_method",
        id: email.id,
    },
});
const lowUrgencySms = new pagerduty.UserNotificationRule("lowUrgencySms", {
    userId: example.id,
    startDelayInMinutes: 10,
    urgency: "low",
    contactMethod: {
        type: "sms_contact_method",
        id: sms.id,
    },
});

Create a UserNotificationRule Resource

new UserNotificationRule(name: string, args: UserNotificationRuleArgs, opts?: CustomResourceOptions);
@overload
def UserNotificationRule(resource_name: str,
                         opts: Optional[ResourceOptions] = None,
                         contact_method: Optional[UserNotificationRuleContactMethodArgs] = None,
                         start_delay_in_minutes: Optional[int] = None,
                         urgency: Optional[str] = None,
                         user_id: Optional[str] = None)
@overload
def UserNotificationRule(resource_name: str,
                         args: UserNotificationRuleArgs,
                         opts: Optional[ResourceOptions] = None)
func NewUserNotificationRule(ctx *Context, name string, args UserNotificationRuleArgs, opts ...ResourceOption) (*UserNotificationRule, error)
public UserNotificationRule(string name, UserNotificationRuleArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args UserNotificationRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args UserNotificationRuleArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args UserNotificationRuleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args UserNotificationRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

UserNotificationRule Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The UserNotificationRule resource accepts the following input properties:

ContactMethod UserNotificationRuleContactMethodArgs
A contact method block, configured as a block described below.
StartDelayInMinutes int
The delay before firing the rule, in minutes.
Urgency string
Which incident urgency this rule is used for. Account must have the urgencies ability to have a low urgency notification rule. Can be high or low.
UserId string
The ID of the user.
ContactMethod UserNotificationRuleContactMethod
A contact method block, configured as a block described below.
StartDelayInMinutes int
The delay before firing the rule, in minutes.
Urgency string
Which incident urgency this rule is used for. Account must have the urgencies ability to have a low urgency notification rule. Can be high or low.
UserId string
The ID of the user.
contactMethod UserNotificationRuleContactMethodArgs
A contact method block, configured as a block described below.
startDelayInMinutes number
The delay before firing the rule, in minutes.
urgency string
Which incident urgency this rule is used for. Account must have the urgencies ability to have a low urgency notification rule. Can be high or low.
userId string
The ID of the user.
contact_method UserNotificationRuleContactMethodArgs
A contact method block, configured as a block described below.
start_delay_in_minutes int
The delay before firing the rule, in minutes.
urgency str
Which incident urgency this rule is used for. Account must have the urgencies ability to have a low urgency notification rule. Can be high or low.
user_id str
The ID of the user.

Outputs

All input properties are implicitly available as output properties. Additionally, the UserNotificationRule resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.

Look up an Existing UserNotificationRule Resource

Get an existing UserNotificationRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: UserNotificationRuleState, opts?: CustomResourceOptions): UserNotificationRule
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        contact_method: Optional[UserNotificationRuleContactMethodArgs] = None,
        start_delay_in_minutes: Optional[int] = None,
        urgency: Optional[str] = None,
        user_id: Optional[str] = None) -> UserNotificationRule
func GetUserNotificationRule(ctx *Context, name string, id IDInput, state *UserNotificationRuleState, opts ...ResourceOption) (*UserNotificationRule, error)
public static UserNotificationRule Get(string name, Input<string> id, UserNotificationRuleState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

ContactMethod UserNotificationRuleContactMethodArgs
A contact method block, configured as a block described below.
StartDelayInMinutes int
The delay before firing the rule, in minutes.
Urgency string
Which incident urgency this rule is used for. Account must have the urgencies ability to have a low urgency notification rule. Can be high or low.
UserId string
The ID of the user.
ContactMethod UserNotificationRuleContactMethod
A contact method block, configured as a block described below.
StartDelayInMinutes int
The delay before firing the rule, in minutes.
Urgency string
Which incident urgency this rule is used for. Account must have the urgencies ability to have a low urgency notification rule. Can be high or low.
UserId string
The ID of the user.
contactMethod UserNotificationRuleContactMethodArgs
A contact method block, configured as a block described below.
startDelayInMinutes number
The delay before firing the rule, in minutes.
urgency string
Which incident urgency this rule is used for. Account must have the urgencies ability to have a low urgency notification rule. Can be high or low.
userId string
The ID of the user.
contact_method UserNotificationRuleContactMethodArgs
A contact method block, configured as a block described below.
start_delay_in_minutes int
The delay before firing the rule, in minutes.
urgency str
Which incident urgency this rule is used for. Account must have the urgencies ability to have a low urgency notification rule. Can be high or low.
user_id str
The ID of the user.

Supporting Types

UserNotificationRuleContactMethod

Id string
The id of the referenced contact method.
Type string
The type of contact method. Can be email_contact_method, phone_contact_method, push_notification_contact_method or sms_contact_method.
Id string
The id of the referenced contact method.
Type string
The type of contact method. Can be email_contact_method, phone_contact_method, push_notification_contact_method or sms_contact_method.
id string
The id of the referenced contact method.
type string
The type of contact method. Can be email_contact_method, phone_contact_method, push_notification_contact_method or sms_contact_method.
id str
The id of the referenced contact method.
type str
The type of contact method. Can be email_contact_method, phone_contact_method, push_notification_contact_method or sms_contact_method.

Import

User notification rules can be imported using the user_id and the id, e.g.

 $ pulumi import pagerduty:index/userNotificationRule:UserNotificationRule main PXPGF42:PPSCXAN

Package Details

Repository
https://github.com/pulumi/pulumi-pagerduty
License
Apache-2.0
Notes
This Pulumi package is based on the pagerduty Terraform Provider.