PagerDuty v4.23.1 published on Tuesday, Apr 22, 2025 by Pulumi
pagerduty.getUserContactMethod
Explore with Pulumi AI
Use this data source to get information about a specific contact method of a PagerDuty user that you can use for other PagerDuty resources.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as pagerduty from "@pulumi/pagerduty";
const me = pagerduty.getUser({
    email: "me@example.com",
});
const phonePush = me.then(me => pagerduty.getUserContactMethod({
    userId: me.id,
    type: "push_notification_contact_method",
    label: "iPhone (John)",
}));
const lowUrgencySms = new pagerduty.UserNotificationRule("low_urgency_sms", {
    userId: me.then(me => me.id),
    startDelayInMinutes: 5,
    urgency: "high",
    contactMethod: {
        type: "push_notification_contact_method",
        id: phonePush.then(phonePush => phonePush.id),
    },
});
import pulumi
import pulumi_pagerduty as pagerduty
me = pagerduty.get_user(email="me@example.com")
phone_push = pagerduty.get_user_contact_method(user_id=me.id,
    type="push_notification_contact_method",
    label="iPhone (John)")
low_urgency_sms = pagerduty.UserNotificationRule("low_urgency_sms",
    user_id=me.id,
    start_delay_in_minutes=5,
    urgency="high",
    contact_method={
        "type": "push_notification_contact_method",
        "id": phone_push.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 {
		me, err := pagerduty.LookupUser(ctx, &pagerduty.LookupUserArgs{
			Email: "me@example.com",
		}, nil)
		if err != nil {
			return err
		}
		phonePush, err := pagerduty.LookupUserContactMethod(ctx, &pagerduty.LookupUserContactMethodArgs{
			UserId: me.Id,
			Type:   "push_notification_contact_method",
			Label:  "iPhone (John)",
		}, nil)
		if err != nil {
			return err
		}
		_, err = pagerduty.NewUserNotificationRule(ctx, "low_urgency_sms", &pagerduty.UserNotificationRuleArgs{
			UserId:              pulumi.String(me.Id),
			StartDelayInMinutes: pulumi.Int(5),
			Urgency:             pulumi.String("high"),
			ContactMethod: &pagerduty.UserNotificationRuleContactMethodArgs{
				Type: pulumi.String("push_notification_contact_method"),
				Id:   pulumi.String(phonePush.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 me = Pagerduty.GetUser.Invoke(new()
    {
        Email = "me@example.com",
    });
    var phonePush = Pagerduty.GetUserContactMethod.Invoke(new()
    {
        UserId = me.Apply(getUserResult => getUserResult.Id),
        Type = "push_notification_contact_method",
        Label = "iPhone (John)",
    });
    var lowUrgencySms = new Pagerduty.UserNotificationRule("low_urgency_sms", new()
    {
        UserId = me.Apply(getUserResult => getUserResult.Id),
        StartDelayInMinutes = 5,
        Urgency = "high",
        ContactMethod = new Pagerduty.Inputs.UserNotificationRuleContactMethodArgs
        {
            Type = "push_notification_contact_method",
            Id = phonePush.Apply(getUserContactMethodResult => getUserContactMethodResult.Id),
        },
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.pagerduty.PagerdutyFunctions;
import com.pulumi.pagerduty.inputs.GetUserArgs;
import com.pulumi.pagerduty.inputs.GetUserContactMethodArgs;
import com.pulumi.pagerduty.UserNotificationRule;
import com.pulumi.pagerduty.UserNotificationRuleArgs;
import com.pulumi.pagerduty.inputs.UserNotificationRuleContactMethodArgs;
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) {
        final var me = PagerdutyFunctions.getUser(GetUserArgs.builder()
            .email("me@example.com")
            .build());
        final var phonePush = PagerdutyFunctions.getUserContactMethod(GetUserContactMethodArgs.builder()
            .userId(me.id())
            .type("push_notification_contact_method")
            .label("iPhone (John)")
            .build());
        var lowUrgencySms = new UserNotificationRule("lowUrgencySms", UserNotificationRuleArgs.builder()
            .userId(me.id())
            .startDelayInMinutes(5)
            .urgency("high")
            .contactMethod(UserNotificationRuleContactMethodArgs.builder()
                .type("push_notification_contact_method")
                .id(phonePush.id())
                .build())
            .build());
    }
}
resources:
  lowUrgencySms:
    type: pagerduty:UserNotificationRule
    name: low_urgency_sms
    properties:
      userId: ${me.id}
      startDelayInMinutes: 5
      urgency: high
      contactMethod:
        type: push_notification_contact_method
        id: ${phonePush.id}
variables:
  me:
    fn::invoke:
      function: pagerduty:getUser
      arguments:
        email: me@example.com
  phonePush:
    fn::invoke:
      function: pagerduty:getUserContactMethod
      arguments:
        userId: ${me.id}
        type: push_notification_contact_method
        label: iPhone (John)
Using getUserContactMethod
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getUserContactMethod(args: GetUserContactMethodArgs, opts?: InvokeOptions): Promise<GetUserContactMethodResult>
function getUserContactMethodOutput(args: GetUserContactMethodOutputArgs, opts?: InvokeOptions): Output<GetUserContactMethodResult>def get_user_contact_method(label: Optional[str] = None,
                            type: Optional[str] = None,
                            user_id: Optional[str] = None,
                            opts: Optional[InvokeOptions] = None) -> GetUserContactMethodResult
def get_user_contact_method_output(label: Optional[pulumi.Input[str]] = None,
                            type: Optional[pulumi.Input[str]] = None,
                            user_id: Optional[pulumi.Input[str]] = None,
                            opts: Optional[InvokeOptions] = None) -> Output[GetUserContactMethodResult]func LookupUserContactMethod(ctx *Context, args *LookupUserContactMethodArgs, opts ...InvokeOption) (*LookupUserContactMethodResult, error)
func LookupUserContactMethodOutput(ctx *Context, args *LookupUserContactMethodOutputArgs, opts ...InvokeOption) LookupUserContactMethodResultOutput> Note: This function is named LookupUserContactMethod in the Go SDK.
public static class GetUserContactMethod 
{
    public static Task<GetUserContactMethodResult> InvokeAsync(GetUserContactMethodArgs args, InvokeOptions? opts = null)
    public static Output<GetUserContactMethodResult> Invoke(GetUserContactMethodInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetUserContactMethodResult> getUserContactMethod(GetUserContactMethodArgs args, InvokeOptions options)
public static Output<GetUserContactMethodResult> getUserContactMethod(GetUserContactMethodArgs args, InvokeOptions options)
fn::invoke:
  function: pagerduty:index/getUserContactMethod:getUserContactMethod
  arguments:
    # arguments dictionaryThe following arguments are supported:
getUserContactMethod Result
The following output properties are available:
- Address string
 - The "address" to deliver to: 
email,phone number, etc., depending on the type. - Blacklisted bool
 - If true, this phone has been blacklisted by PagerDuty and no messages will be sent to it. (Phone and SMS contact methods only.)
 - Country
Code int - The 1-to-3 digit country calling code. (Phone and SMS contact methods only.)
 - Device
Type string - Either 
iosorandroid, depending on the type of the device receiving notifications. (Push notification contact method only.) - Enabled bool
 - If true, this phone is capable of receiving SMS messages. (Phone and SMS contact methods only.)
 - Id string
 - The provider-assigned unique ID for this managed resource.
 - Label string
 - The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
 - Send
Short boolEmail  - Send an abbreviated email message instead of the standard email output. (Email contact method only.)
 - Type string
 - The type of the found contact method. May be (
email_contact_method,phone_contact_method,sms_contact_method,push_notification_contact_method). - User
Id string 
- Address string
 - The "address" to deliver to: 
email,phone number, etc., depending on the type. - Blacklisted bool
 - If true, this phone has been blacklisted by PagerDuty and no messages will be sent to it. (Phone and SMS contact methods only.)
 - Country
Code int - The 1-to-3 digit country calling code. (Phone and SMS contact methods only.)
 - Device
Type string - Either 
iosorandroid, depending on the type of the device receiving notifications. (Push notification contact method only.) - Enabled bool
 - If true, this phone is capable of receiving SMS messages. (Phone and SMS contact methods only.)
 - Id string
 - The provider-assigned unique ID for this managed resource.
 - Label string
 - The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
 - Send
Short boolEmail  - Send an abbreviated email message instead of the standard email output. (Email contact method only.)
 - Type string
 - The type of the found contact method. May be (
email_contact_method,phone_contact_method,sms_contact_method,push_notification_contact_method). - User
Id string 
- address String
 - The "address" to deliver to: 
email,phone number, etc., depending on the type. - blacklisted Boolean
 - If true, this phone has been blacklisted by PagerDuty and no messages will be sent to it. (Phone and SMS contact methods only.)
 - country
Code Integer - The 1-to-3 digit country calling code. (Phone and SMS contact methods only.)
 - device
Type String - Either 
iosorandroid, depending on the type of the device receiving notifications. (Push notification contact method only.) - enabled Boolean
 - If true, this phone is capable of receiving SMS messages. (Phone and SMS contact methods only.)
 - id String
 - The provider-assigned unique ID for this managed resource.
 - label String
 - The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
 - send
Short BooleanEmail  - Send an abbreviated email message instead of the standard email output. (Email contact method only.)
 - type String
 - The type of the found contact method. May be (
email_contact_method,phone_contact_method,sms_contact_method,push_notification_contact_method). - user
Id String 
- address string
 - The "address" to deliver to: 
email,phone number, etc., depending on the type. - blacklisted boolean
 - If true, this phone has been blacklisted by PagerDuty and no messages will be sent to it. (Phone and SMS contact methods only.)
 - country
Code number - The 1-to-3 digit country calling code. (Phone and SMS contact methods only.)
 - device
Type string - Either 
iosorandroid, depending on the type of the device receiving notifications. (Push notification contact method only.) - enabled boolean
 - If true, this phone is capable of receiving SMS messages. (Phone and SMS contact methods only.)
 - id string
 - The provider-assigned unique ID for this managed resource.
 - label string
 - The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
 - send
Short booleanEmail  - Send an abbreviated email message instead of the standard email output. (Email contact method only.)
 - type string
 - The type of the found contact method. May be (
email_contact_method,phone_contact_method,sms_contact_method,push_notification_contact_method). - user
Id string 
- address str
 - The "address" to deliver to: 
email,phone number, etc., depending on the type. - blacklisted bool
 - If true, this phone has been blacklisted by PagerDuty and no messages will be sent to it. (Phone and SMS contact methods only.)
 - country_
code int - The 1-to-3 digit country calling code. (Phone and SMS contact methods only.)
 - device_
type str - Either 
iosorandroid, depending on the type of the device receiving notifications. (Push notification contact method only.) - enabled bool
 - If true, this phone is capable of receiving SMS messages. (Phone and SMS contact methods only.)
 - id str
 - The provider-assigned unique ID for this managed resource.
 - label str
 - The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
 - send_
short_ boolemail  - Send an abbreviated email message instead of the standard email output. (Email contact method only.)
 - type str
 - The type of the found contact method. May be (
email_contact_method,phone_contact_method,sms_contact_method,push_notification_contact_method). - user_
id str 
- address String
 - The "address" to deliver to: 
email,phone number, etc., depending on the type. - blacklisted Boolean
 - If true, this phone has been blacklisted by PagerDuty and no messages will be sent to it. (Phone and SMS contact methods only.)
 - country
Code Number - The 1-to-3 digit country calling code. (Phone and SMS contact methods only.)
 - device
Type String - Either 
iosorandroid, depending on the type of the device receiving notifications. (Push notification contact method only.) - enabled Boolean
 - If true, this phone is capable of receiving SMS messages. (Phone and SMS contact methods only.)
 - id String
 - The provider-assigned unique ID for this managed resource.
 - label String
 - The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
 - send
Short BooleanEmail  - Send an abbreviated email message instead of the standard email output. (Email contact method only.)
 - type String
 - The type of the found contact method. May be (
email_contact_method,phone_contact_method,sms_contact_method,push_notification_contact_method). - user
Id String 
Package Details
- Repository
 - PagerDuty pulumi/pulumi-pagerduty
 - License
 - Apache-2.0
 - Notes
 - This Pulumi package is based on the 
pagerdutyTerraform Provider.