1. Packages
  2. PagerDuty
  3. API Docs
  4. UserNotificationRule
PagerDuty v4.10.1 published on Wednesday, Mar 27, 2024 by Pulumi

pagerduty.UserNotificationRule

Explore with Pulumi AI

pagerduty logo
PagerDuty v4.10.1 published on Wednesday, Mar 27, 2024 by Pulumi

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

    Example Usage

    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,
        },
    });
    
    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={
            "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={
            "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={
            "type": "sms_contact_method",
            "id": sms.id,
        })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-pagerduty/sdk/v4/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: pulumi.StringMap{
    				"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: pulumi.StringMap{
    				"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: pulumi.StringMap{
    				"type": pulumi.String("sms_contact_method"),
    				"id":   sms.ID(),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Pagerduty = Pulumi.Pagerduty;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Pagerduty.User("example", new()
        {
            Email = "125.greenholt.earline@graham.name",
        });
    
        var email = new Pagerduty.UserContactMethod("email", new()
        {
            UserId = example.Id,
            Type = "email_contact_method",
            Address = "foo@bar.com",
            Label = "Work",
        });
    
        var phone = new Pagerduty.UserContactMethod("phone", new()
        {
            UserId = example.Id,
            Type = "phone_contact_method",
            CountryCode = 1,
            Address = "2025550199",
            Label = "Work",
        });
    
        var sms = new Pagerduty.UserContactMethod("sms", new()
        {
            UserId = example.Id,
            Type = "sms_contact_method",
            CountryCode = 1,
            Address = "2025550199",
            Label = "Work",
        });
    
        var highUrgencyPhone = new Pagerduty.UserNotificationRule("highUrgencyPhone", new()
        {
            UserId = example.Id,
            StartDelayInMinutes = 1,
            Urgency = "high",
            ContactMethod = 
            {
                { "type", "phone_contact_method" },
                { "id", phone.Id },
            },
        });
    
        var lowUrgencyEmail = new Pagerduty.UserNotificationRule("lowUrgencyEmail", new()
        {
            UserId = example.Id,
            StartDelayInMinutes = 1,
            Urgency = "low",
            ContactMethod = 
            {
                { "type", "email_contact_method" },
                { "id", email.Id },
            },
        });
    
        var lowUrgencySms = new Pagerduty.UserNotificationRule("lowUrgencySms", new()
        {
            UserId = example.Id,
            StartDelayInMinutes = 10,
            Urgency = "low",
            ContactMethod = 
            {
                { "type", "sms_contact_method" },
                { "id", sms.Id },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.pagerduty.User;
    import com.pulumi.pagerduty.UserArgs;
    import com.pulumi.pagerduty.UserContactMethod;
    import com.pulumi.pagerduty.UserContactMethodArgs;
    import com.pulumi.pagerduty.UserNotificationRule;
    import com.pulumi.pagerduty.UserNotificationRuleArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var example = new User("example", UserArgs.builder()        
                .email("125.greenholt.earline@graham.name")
                .build());
    
            var email = new UserContactMethod("email", UserContactMethodArgs.builder()        
                .userId(example.id())
                .type("email_contact_method")
                .address("foo@bar.com")
                .label("Work")
                .build());
    
            var phone = new UserContactMethod("phone", UserContactMethodArgs.builder()        
                .userId(example.id())
                .type("phone_contact_method")
                .countryCode("+1")
                .address("2025550199")
                .label("Work")
                .build());
    
            var sms = new UserContactMethod("sms", UserContactMethodArgs.builder()        
                .userId(example.id())
                .type("sms_contact_method")
                .countryCode("+1")
                .address("2025550199")
                .label("Work")
                .build());
    
            var highUrgencyPhone = new UserNotificationRule("highUrgencyPhone", UserNotificationRuleArgs.builder()        
                .userId(example.id())
                .startDelayInMinutes(1)
                .urgency("high")
                .contactMethod(Map.ofEntries(
                    Map.entry("type", "phone_contact_method"),
                    Map.entry("id", phone.id())
                ))
                .build());
    
            var lowUrgencyEmail = new UserNotificationRule("lowUrgencyEmail", UserNotificationRuleArgs.builder()        
                .userId(example.id())
                .startDelayInMinutes(1)
                .urgency("low")
                .contactMethod(Map.ofEntries(
                    Map.entry("type", "email_contact_method"),
                    Map.entry("id", email.id())
                ))
                .build());
    
            var lowUrgencySms = new UserNotificationRule("lowUrgencySms", UserNotificationRuleArgs.builder()        
                .userId(example.id())
                .startDelayInMinutes(10)
                .urgency("low")
                .contactMethod(Map.ofEntries(
                    Map.entry("type", "sms_contact_method"),
                    Map.entry("id", sms.id())
                ))
                .build());
    
        }
    }
    
    resources:
      example:
        type: pagerduty:User
        properties:
          email: 125.greenholt.earline@graham.name
      email:
        type: pagerduty:UserContactMethod
        properties:
          userId: ${example.id}
          type: email_contact_method
          address: foo@bar.com
          label: Work
      phone:
        type: pagerduty:UserContactMethod
        properties:
          userId: ${example.id}
          type: phone_contact_method
          countryCode: '+1'
          address: '2025550199'
          label: Work
      sms:
        type: pagerduty:UserContactMethod
        properties:
          userId: ${example.id}
          type: sms_contact_method
          countryCode: '+1'
          address: '2025550199'
          label: Work
      highUrgencyPhone:
        type: pagerduty:UserNotificationRule
        properties:
          userId: ${example.id}
          startDelayInMinutes: 1
          urgency: high
          contactMethod:
            type: phone_contact_method
            id: ${phone.id}
      lowUrgencyEmail:
        type: pagerduty:UserNotificationRule
        properties:
          userId: ${example.id}
          startDelayInMinutes: 1
          urgency: low
          contactMethod:
            type: email_contact_method
            id: ${email.id}
      lowUrgencySms:
        type: pagerduty:UserNotificationRule
        properties:
          userId: ${example.id}
          startDelayInMinutes: 10
          urgency: low
          contactMethod:
            type: sms_contact_method
            id: ${sms.id}
    

    Create UserNotificationRule Resource

    new UserNotificationRule(name: string, args: UserNotificationRuleArgs, opts?: CustomResourceOptions);
    @overload
    def UserNotificationRule(resource_name: str,
                             opts: Optional[ResourceOptions] = None,
                             contact_method: Optional[Mapping[str, str]] = 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)
    public UserNotificationRule(String name, UserNotificationRuleArgs args)
    public UserNotificationRule(String name, UserNotificationRuleArgs args, CustomResourceOptions options)
    
    type: pagerduty:UserNotificationRule
    properties: # The arguments to resource properties.
    options: # 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.
    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.
    name String
    The unique name of the resource.
    args UserNotificationRuleArgs
    The arguments to resource properties.
    options 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 Architecture and Concepts docs.

    Inputs

    The UserNotificationRule resource accepts the following input properties:

    ContactMethod Dictionary<string, string>
    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 map[string]string
    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 Map<String,String>
    A contact method block, configured as a block described below.
    startDelayInMinutes Integer
    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 {[key: string]: string}
    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 Mapping[str, str]
    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.
    contactMethod Map<String>
    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.

    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 string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up 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[Mapping[str, str]] = 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)
    public static UserNotificationRule get(String name, Output<String> id, UserNotificationRuleState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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.
    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 Dictionary<string, string>
    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 map[string]string
    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 Map<String,String>
    A contact method block, configured as a block described below.
    startDelayInMinutes Integer
    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 {[key: string]: string}
    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 Mapping[str, str]
    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.
    contactMethod Map<String>
    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.

    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
    PagerDuty pulumi/pulumi-pagerduty
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the pagerduty Terraform Provider.
    pagerduty logo
    PagerDuty v4.10.1 published on Wednesday, Mar 27, 2024 by Pulumi