1. Packages
  2. PagerDuty
  3. API Docs
  4. UserNotificationRule
PagerDuty v4.12.3 published on Tuesday, May 21, 2024 by Pulumi

pagerduty.UserNotificationRule

Explore with Pulumi AI

pagerduty logo
PagerDuty v4.12.3 published on Tuesday, May 21, 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", {
        name: "Earline Greenholt",
        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("high_urgency_phone", {
        userId: example.id,
        startDelayInMinutes: 1,
        urgency: "high",
        contactMethod: {
            type: "phone_contact_method",
            id: phone.id,
        },
    });
    const lowUrgencyEmail = new pagerduty.UserNotificationRule("low_urgency_email", {
        userId: example.id,
        startDelayInMinutes: 1,
        urgency: "low",
        contactMethod: {
            type: "email_contact_method",
            id: email.id,
        },
    });
    const lowUrgencySms = new pagerduty.UserNotificationRule("low_urgency_sms", {
        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",
        name="Earline Greenholt",
        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("high_urgency_phone",
        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("low_urgency_email",
        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("low_urgency_sms",
        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{
    			Name:  pulumi.String("Earline Greenholt"),
    			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, "high_urgency_phone", &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, "low_urgency_email", &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, "low_urgency_sms", &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()
        {
            Name = "Earline Greenholt",
            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("high_urgency_phone", new()
        {
            UserId = example.Id,
            StartDelayInMinutes = 1,
            Urgency = "high",
            ContactMethod = 
            {
                { "type", "phone_contact_method" },
                { "id", phone.Id },
            },
        });
    
        var lowUrgencyEmail = new Pagerduty.UserNotificationRule("low_urgency_email", new()
        {
            UserId = example.Id,
            StartDelayInMinutes = 1,
            Urgency = "low",
            ContactMethod = 
            {
                { "type", "email_contact_method" },
                { "id", email.Id },
            },
        });
    
        var lowUrgencySms = new Pagerduty.UserNotificationRule("low_urgency_sms", 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()        
                .name("Earline Greenholt")
                .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:
          name: Earline Greenholt
          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
        name: high_urgency_phone
        properties:
          userId: ${example.id}
          startDelayInMinutes: 1
          urgency: high
          contactMethod:
            type: phone_contact_method
            id: ${phone.id}
      lowUrgencyEmail:
        type: pagerduty:UserNotificationRule
        name: low_urgency_email
        properties:
          userId: ${example.id}
          startDelayInMinutes: 1
          urgency: low
          contactMethod:
            type: email_contact_method
            id: ${email.id}
      lowUrgencySms:
        type: pagerduty:UserNotificationRule
        name: low_urgency_sms
        properties:
          userId: ${example.id}
          startDelayInMinutes: 10
          urgency: low
          contactMethod:
            type: sms_contact_method
            id: ${sms.id}
    

    Create UserNotificationRule Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new UserNotificationRule(name: string, args: UserNotificationRuleArgs, opts?: CustomResourceOptions);
    @overload
    def UserNotificationRule(resource_name: str,
                             args: UserNotificationRuleArgs,
                             opts: Optional[ResourceOptions] = None)
    
    @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)
    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.
    
    

    Parameters

    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.

    Example

    The following reference example uses placeholder values for all input properties.

    var userNotificationRuleResource = new Pagerduty.UserNotificationRule("userNotificationRuleResource", new()
    {
        ContactMethod = 
        {
            { "string", "string" },
        },
        StartDelayInMinutes = 0,
        Urgency = "string",
        UserId = "string",
    });
    
    example, err := pagerduty.NewUserNotificationRule(ctx, "userNotificationRuleResource", &pagerduty.UserNotificationRuleArgs{
    	ContactMethod: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    	StartDelayInMinutes: pulumi.Int(0),
    	Urgency:             pulumi.String("string"),
    	UserId:              pulumi.String("string"),
    })
    
    var userNotificationRuleResource = new UserNotificationRule("userNotificationRuleResource", UserNotificationRuleArgs.builder()
        .contactMethod(Map.of("string", "string"))
        .startDelayInMinutes(0)
        .urgency("string")
        .userId("string")
        .build());
    
    user_notification_rule_resource = pagerduty.UserNotificationRule("userNotificationRuleResource",
        contact_method={
            "string": "string",
        },
        start_delay_in_minutes=0,
        urgency="string",
        user_id="string")
    
    const userNotificationRuleResource = new pagerduty.UserNotificationRule("userNotificationRuleResource", {
        contactMethod: {
            string: "string",
        },
        startDelayInMinutes: 0,
        urgency: "string",
        userId: "string",
    });
    
    type: pagerduty:UserNotificationRule
    properties:
        contactMethod:
            string: string
        startDelayInMinutes: 0
        urgency: string
        userId: string
    

    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>
    StartDelayInMinutes int
    Urgency string
    UserId string
    ContactMethod map[string]string
    StartDelayInMinutes int
    Urgency string
    UserId string
    contactMethod Map<String,String>
    startDelayInMinutes Integer
    urgency String
    userId String
    contactMethod {[key: string]: string}
    startDelayInMinutes number
    urgency string
    userId string
    contactMethod Map<String>
    startDelayInMinutes Number
    urgency String
    userId String

    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>
    StartDelayInMinutes int
    Urgency string
    UserId string
    ContactMethod map[string]string
    StartDelayInMinutes int
    Urgency string
    UserId string
    contactMethod Map<String,String>
    startDelayInMinutes Integer
    urgency String
    userId String
    contactMethod {[key: string]: string}
    startDelayInMinutes number
    urgency string
    userId string
    contactMethod Map<String>
    startDelayInMinutes Number
    urgency String
    userId String

    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
    

    To learn more about importing existing cloud resources, see Importing resources.

    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.12.3 published on Tuesday, May 21, 2024 by Pulumi