pagerduty logo
PagerDuty v3.9.0, Mar 14 23

pagerduty.EventRule

NOTE: The pagerduty.EventRule resource has been deprecated in favor of the pagerduty.Ruleset and pagerduty.RulesetRule resources. Please use the ruleset based resources for working with Event Rules.

An event rule determines what happens to an event that is sent to PagerDuty by monitoring tools and other integrations.

Example Usage

using System.Collections.Generic;
using System.Text.Json;
using Pulumi;
using Pagerduty = Pulumi.Pagerduty;

return await Deployment.RunAsync(() => 
{
    var second = new Pagerduty.EventRule("second", new()
    {
        ActionJson = JsonSerializer.Serialize(new[]
        {
            new[]
            {
                "route",
                "P5DTL0K",
            },
            new[]
            {
                "severity",
                "warning",
            },
            new[]
            {
                "annotate",
                "2 Managed by terraform",
            },
            new[]
            {
                "priority",
                "PL451DT",
            },
        }),
        ConditionJson = JsonSerializer.Serialize(new[]
        {
            "and",
            new[]
            {
                "contains",
                new[]
                {
                    "path",
                    "payload",
                    "source",
                },
                "website",
            },
            new[]
            {
                "contains",
                new[]
                {
                    "path",
                    "headers",
                    "from",
                    "0",
                    "address",
                },
                "homer",
            },
        }),
        AdvancedConditionJson = JsonSerializer.Serialize(new[]
        {
            new[]
            {
                "scheduled-weekly",
                1565392127032,
                3600000,
                "America/Los_Angeles",
                new[]
                {
                    1,
                    2,
                    3,
                    5,
                    7,
                },
            },
        }),
    });

    var third = new Pagerduty.EventRule("third", new()
    {
        ActionJson = JsonSerializer.Serialize(new[]
        {
            new[]
            {
                "route",
                "P5DTL0K",
            },
            new[]
            {
                "severity",
                "warning",
            },
            new[]
            {
                "annotate",
                "3 Managed by terraform",
            },
            new[]
            {
                "priority",
                "PL451DT",
            },
        }),
        ConditionJson = JsonSerializer.Serialize(new[]
        {
            "and",
            new[]
            {
                "contains",
                new[]
                {
                    "path",
                    "payload",
                    "source",
                },
                "website",
            },
            new[]
            {
                "contains",
                new[]
                {
                    "path",
                    "headers",
                    "from",
                    "0",
                    "address",
                },
                "homer",
            },
        }),
    }, new CustomResourceOptions
    {
        DependsOn = new[]
        {
            pagerduty_event_rule.Two,
        },
    });

});
package main

import (
	"encoding/json"

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		tmpJSON0, err := json.Marshal([][]string{
			[]string{
				"route",
				"P5DTL0K",
			},
			[]string{
				"severity",
				"warning",
			},
			[]string{
				"annotate",
				"2 Managed by terraform",
			},
			[]string{
				"priority",
				"PL451DT",
			},
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		tmpJSON1, err := json.Marshal([]interface{}{
			"and",
			[]interface{}{
				"contains",
				[]string{
					"path",
					"payload",
					"source",
				},
				"website",
			},
			[]interface{}{
				"contains",
				[]string{
					"path",
					"headers",
					"from",
					"0",
					"address",
				},
				"homer",
			},
		})
		if err != nil {
			return err
		}
		json1 := string(tmpJSON1)
		tmpJSON2, err := json.Marshal([][]interface{}{
			[]interface{}{
				"scheduled-weekly",
				1565392127032,
				3600000,
				"America/Los_Angeles",
				[]float64{
					1,
					2,
					3,
					5,
					7,
				},
			},
		})
		if err != nil {
			return err
		}
		json2 := string(tmpJSON2)
		_, err = pagerduty.NewEventRule(ctx, "second", &pagerduty.EventRuleArgs{
			ActionJson:            pulumi.String(json0),
			ConditionJson:         pulumi.String(json1),
			AdvancedConditionJson: pulumi.String(json2),
		})
		if err != nil {
			return err
		}
		tmpJSON3, err := json.Marshal([][]string{
			[]string{
				"route",
				"P5DTL0K",
			},
			[]string{
				"severity",
				"warning",
			},
			[]string{
				"annotate",
				"3 Managed by terraform",
			},
			[]string{
				"priority",
				"PL451DT",
			},
		})
		if err != nil {
			return err
		}
		json3 := string(tmpJSON3)
		tmpJSON4, err := json.Marshal([]interface{}{
			"and",
			[]interface{}{
				"contains",
				[]string{
					"path",
					"payload",
					"source",
				},
				"website",
			},
			[]interface{}{
				"contains",
				[]string{
					"path",
					"headers",
					"from",
					"0",
					"address",
				},
				"homer",
			},
		})
		if err != nil {
			return err
		}
		json4 := string(tmpJSON4)
		_, err = pagerduty.NewEventRule(ctx, "third", &pagerduty.EventRuleArgs{
			ActionJson:    pulumi.String(json3),
			ConditionJson: pulumi.String(json4),
		}, pulumi.DependsOn([]pulumi.Resource{
			pagerduty_event_rule.Two,
		}))
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.pagerduty.EventRule;
import com.pulumi.pagerduty.EventRuleArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import com.pulumi.resources.CustomResourceOptions;
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 second = new EventRule("second", EventRuleArgs.builder()        
            .actionJson(serializeJson(
                jsonArray(
                    jsonArray(
                        "route", 
                        "P5DTL0K"
                    ), 
                    jsonArray(
                        "severity", 
                        "warning"
                    ), 
                    jsonArray(
                        "annotate", 
                        "2 Managed by terraform"
                    ), 
                    jsonArray(
                        "priority", 
                        "PL451DT"
                    )
                )))
            .conditionJson(serializeJson(
                jsonArray(
                    "and", 
                    jsonArray(
                        "contains", 
                        jsonArray(
                            "path", 
                            "payload", 
                            "source"
                        ), 
                        "website"
                    ), 
                    jsonArray(
                        "contains", 
                        jsonArray(
                            "path", 
                            "headers", 
                            "from", 
                            "0", 
                            "address"
                        ), 
                        "homer"
                    )
                )))
            .advancedConditionJson(serializeJson(
                jsonArray(jsonArray(
                    "scheduled-weekly", 
                    1565392127032, 
                    3600000, 
                    "America/Los_Angeles", 
                    jsonArray(
                        1, 
                        2, 
                        3, 
                        5, 
                        7
                    )
                ))))
            .build());

        var third = new EventRule("third", EventRuleArgs.builder()        
            .actionJson(serializeJson(
                jsonArray(
                    jsonArray(
                        "route", 
                        "P5DTL0K"
                    ), 
                    jsonArray(
                        "severity", 
                        "warning"
                    ), 
                    jsonArray(
                        "annotate", 
                        "3 Managed by terraform"
                    ), 
                    jsonArray(
                        "priority", 
                        "PL451DT"
                    )
                )))
            .conditionJson(serializeJson(
                jsonArray(
                    "and", 
                    jsonArray(
                        "contains", 
                        jsonArray(
                            "path", 
                            "payload", 
                            "source"
                        ), 
                        "website"
                    ), 
                    jsonArray(
                        "contains", 
                        jsonArray(
                            "path", 
                            "headers", 
                            "from", 
                            "0", 
                            "address"
                        ), 
                        "homer"
                    )
                )))
            .build(), CustomResourceOptions.builder()
                .dependsOn(pagerduty_event_rule.two())
                .build());

    }
}
import pulumi
import json
import pulumi_pagerduty as pagerduty

second = pagerduty.EventRule("second",
    action_json=json.dumps([
        [
            "route",
            "P5DTL0K",
        ],
        [
            "severity",
            "warning",
        ],
        [
            "annotate",
            "2 Managed by terraform",
        ],
        [
            "priority",
            "PL451DT",
        ],
    ]),
    condition_json=json.dumps([
        "and",
        [
            "contains",
            [
                "path",
                "payload",
                "source",
            ],
            "website",
        ],
        [
            "contains",
            [
                "path",
                "headers",
                "from",
                "0",
                "address",
            ],
            "homer",
        ],
    ]),
    advanced_condition_json=json.dumps([[
        "scheduled-weekly",
        1565392127032,
        3600000,
        "America/Los_Angeles",
        [
            1,
            2,
            3,
            5,
            7,
        ],
    ]]))
third = pagerduty.EventRule("third",
    action_json=json.dumps([
        [
            "route",
            "P5DTL0K",
        ],
        [
            "severity",
            "warning",
        ],
        [
            "annotate",
            "3 Managed by terraform",
        ],
        [
            "priority",
            "PL451DT",
        ],
    ]),
    condition_json=json.dumps([
        "and",
        [
            "contains",
            [
                "path",
                "payload",
                "source",
            ],
            "website",
        ],
        [
            "contains",
            [
                "path",
                "headers",
                "from",
                "0",
                "address",
            ],
            "homer",
        ],
    ]),
    opts=pulumi.ResourceOptions(depends_on=[pagerduty_event_rule["two"]]))
import * as pulumi from "@pulumi/pulumi";
import * as pagerduty from "@pulumi/pagerduty";

const second = new pagerduty.EventRule("second", {
    actionJson: JSON.stringify([
        [
            "route",
            "P5DTL0K",
        ],
        [
            "severity",
            "warning",
        ],
        [
            "annotate",
            "2 Managed by terraform",
        ],
        [
            "priority",
            "PL451DT",
        ],
    ]),
    conditionJson: JSON.stringify([
        "and",
        [
            "contains",
            [
                "path",
                "payload",
                "source",
            ],
            "website",
        ],
        [
            "contains",
            [
                "path",
                "headers",
                "from",
                "0",
                "address",
            ],
            "homer",
        ],
    ]),
    advancedConditionJson: JSON.stringify([[
        "scheduled-weekly",
        1565392127032,
        3600000,
        "America/Los_Angeles",
        [
            1,
            2,
            3,
            5,
            7,
        ],
    ]]),
});
const third = new pagerduty.EventRule("third", {
    actionJson: JSON.stringify([
        [
            "route",
            "P5DTL0K",
        ],
        [
            "severity",
            "warning",
        ],
        [
            "annotate",
            "3 Managed by terraform",
        ],
        [
            "priority",
            "PL451DT",
        ],
    ]),
    conditionJson: JSON.stringify([
        "and",
        [
            "contains",
            [
                "path",
                "payload",
                "source",
            ],
            "website",
        ],
        [
            "contains",
            [
                "path",
                "headers",
                "from",
                "0",
                "address",
            ],
            "homer",
        ],
    ]),
}, {
    dependsOn: [pagerduty_event_rule.two],
});
resources:
  second:
    type: pagerduty:EventRule
    properties:
      actionJson:
        fn::toJSON:
          - - route
            - P5DTL0K
          - - severity
            - warning
          - - annotate
            - 2 Managed by terraform
          - - priority
            - PL451DT
      conditionJson:
        fn::toJSON:
          - and
          - - contains
            - - path
              - payload
              - source
            - website
          - - contains
            - - path
              - headers
              - from
              - '0'
              - address
            - homer
      advancedConditionJson:
        fn::toJSON:
          - - scheduled-weekly
            - 1.565392127032e+12
            - 3.6e+06
            - America/Los_Angeles
            - - 1
              - 2
              - 3
              - 5
              - 7
  third:
    type: pagerduty:EventRule
    properties:
      actionJson:
        fn::toJSON:
          - - route
            - P5DTL0K
          - - severity
            - warning
          - - annotate
            - 3 Managed by terraform
          - - priority
            - PL451DT
      conditionJson:
        fn::toJSON:
          - and
          - - contains
            - - path
              - payload
              - source
            - website
          - - contains
            - - path
              - headers
              - from
              - '0'
              - address
            - homer
    options:
      dependson:
        - ${pagerduty_event_rule.two}

Create EventRule Resource

new EventRule(name: string, args: EventRuleArgs, opts?: CustomResourceOptions);
@overload
def EventRule(resource_name: str,
              opts: Optional[ResourceOptions] = None,
              action_json: Optional[str] = None,
              advanced_condition_json: Optional[str] = None,
              condition_json: Optional[str] = None)
@overload
def EventRule(resource_name: str,
              args: EventRuleArgs,
              opts: Optional[ResourceOptions] = None)
func NewEventRule(ctx *Context, name string, args EventRuleArgs, opts ...ResourceOption) (*EventRule, error)
public EventRule(string name, EventRuleArgs args, CustomResourceOptions? opts = null)
public EventRule(String name, EventRuleArgs args)
public EventRule(String name, EventRuleArgs args, CustomResourceOptions options)
type: pagerduty:EventRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args EventRuleArgs
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 EventRuleArgs
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 EventRuleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args EventRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args EventRuleArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

EventRule 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 EventRule resource accepts the following input properties:

ActionJson string

A list of one or more actions for each rule. Each action within the list is itself a list.

ConditionJson string

Contains a list of conditions. The first field in the list is and or or, followed by a list of operators and values.

AdvancedConditionJson string

Contains a list of specific conditions including active-between,scheduled-weekly, and frequency-over. The first element in the list is the label for the condition, followed by a list of values for the specific condition. For more details on these conditions see Advanced Condition in the PagerDuty API documentation.

ActionJson string

A list of one or more actions for each rule. Each action within the list is itself a list.

ConditionJson string

Contains a list of conditions. The first field in the list is and or or, followed by a list of operators and values.

AdvancedConditionJson string

Contains a list of specific conditions including active-between,scheduled-weekly, and frequency-over. The first element in the list is the label for the condition, followed by a list of values for the specific condition. For more details on these conditions see Advanced Condition in the PagerDuty API documentation.

actionJson String

A list of one or more actions for each rule. Each action within the list is itself a list.

conditionJson String

Contains a list of conditions. The first field in the list is and or or, followed by a list of operators and values.

advancedConditionJson String

Contains a list of specific conditions including active-between,scheduled-weekly, and frequency-over. The first element in the list is the label for the condition, followed by a list of values for the specific condition. For more details on these conditions see Advanced Condition in the PagerDuty API documentation.

actionJson string

A list of one or more actions for each rule. Each action within the list is itself a list.

conditionJson string

Contains a list of conditions. The first field in the list is and or or, followed by a list of operators and values.

advancedConditionJson string

Contains a list of specific conditions including active-between,scheduled-weekly, and frequency-over. The first element in the list is the label for the condition, followed by a list of values for the specific condition. For more details on these conditions see Advanced Condition in the PagerDuty API documentation.

action_json str

A list of one or more actions for each rule. Each action within the list is itself a list.

condition_json str

Contains a list of conditions. The first field in the list is and or or, followed by a list of operators and values.

advanced_condition_json str

Contains a list of specific conditions including active-between,scheduled-weekly, and frequency-over. The first element in the list is the label for the condition, followed by a list of values for the specific condition. For more details on these conditions see Advanced Condition in the PagerDuty API documentation.

actionJson String

A list of one or more actions for each rule. Each action within the list is itself a list.

conditionJson String

Contains a list of conditions. The first field in the list is and or or, followed by a list of operators and values.

advancedConditionJson String

Contains a list of specific conditions including active-between,scheduled-weekly, and frequency-over. The first element in the list is the label for the condition, followed by a list of values for the specific condition. For more details on these conditions see Advanced Condition in the PagerDuty API documentation.

Outputs

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

CatchAll bool

A boolean that indicates whether the rule is a catch-all for the account. This field is read-only through the PagerDuty API.

Id string

The provider-assigned unique ID for this managed resource.

CatchAll bool

A boolean that indicates whether the rule is a catch-all for the account. This field is read-only through the PagerDuty API.

Id string

The provider-assigned unique ID for this managed resource.

catchAll Boolean

A boolean that indicates whether the rule is a catch-all for the account. This field is read-only through the PagerDuty API.

id String

The provider-assigned unique ID for this managed resource.

catchAll boolean

A boolean that indicates whether the rule is a catch-all for the account. This field is read-only through the PagerDuty API.

id string

The provider-assigned unique ID for this managed resource.

catch_all bool

A boolean that indicates whether the rule is a catch-all for the account. This field is read-only through the PagerDuty API.

id str

The provider-assigned unique ID for this managed resource.

catchAll Boolean

A boolean that indicates whether the rule is a catch-all for the account. This field is read-only through the PagerDuty API.

id String

The provider-assigned unique ID for this managed resource.

Look up Existing EventRule Resource

Get an existing EventRule 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?: EventRuleState, opts?: CustomResourceOptions): EventRule
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        action_json: Optional[str] = None,
        advanced_condition_json: Optional[str] = None,
        catch_all: Optional[bool] = None,
        condition_json: Optional[str] = None) -> EventRule
func GetEventRule(ctx *Context, name string, id IDInput, state *EventRuleState, opts ...ResourceOption) (*EventRule, error)
public static EventRule Get(string name, Input<string> id, EventRuleState? state, CustomResourceOptions? opts = null)
public static EventRule get(String name, Output<String> id, EventRuleState 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:
ActionJson string

A list of one or more actions for each rule. Each action within the list is itself a list.

AdvancedConditionJson string

Contains a list of specific conditions including active-between,scheduled-weekly, and frequency-over. The first element in the list is the label for the condition, followed by a list of values for the specific condition. For more details on these conditions see Advanced Condition in the PagerDuty API documentation.

CatchAll bool

A boolean that indicates whether the rule is a catch-all for the account. This field is read-only through the PagerDuty API.

ConditionJson string

Contains a list of conditions. The first field in the list is and or or, followed by a list of operators and values.

ActionJson string

A list of one or more actions for each rule. Each action within the list is itself a list.

AdvancedConditionJson string

Contains a list of specific conditions including active-between,scheduled-weekly, and frequency-over. The first element in the list is the label for the condition, followed by a list of values for the specific condition. For more details on these conditions see Advanced Condition in the PagerDuty API documentation.

CatchAll bool

A boolean that indicates whether the rule is a catch-all for the account. This field is read-only through the PagerDuty API.

ConditionJson string

Contains a list of conditions. The first field in the list is and or or, followed by a list of operators and values.

actionJson String

A list of one or more actions for each rule. Each action within the list is itself a list.

advancedConditionJson String

Contains a list of specific conditions including active-between,scheduled-weekly, and frequency-over. The first element in the list is the label for the condition, followed by a list of values for the specific condition. For more details on these conditions see Advanced Condition in the PagerDuty API documentation.

catchAll Boolean

A boolean that indicates whether the rule is a catch-all for the account. This field is read-only through the PagerDuty API.

conditionJson String

Contains a list of conditions. The first field in the list is and or or, followed by a list of operators and values.

actionJson string

A list of one or more actions for each rule. Each action within the list is itself a list.

advancedConditionJson string

Contains a list of specific conditions including active-between,scheduled-weekly, and frequency-over. The first element in the list is the label for the condition, followed by a list of values for the specific condition. For more details on these conditions see Advanced Condition in the PagerDuty API documentation.

catchAll boolean

A boolean that indicates whether the rule is a catch-all for the account. This field is read-only through the PagerDuty API.

conditionJson string

Contains a list of conditions. The first field in the list is and or or, followed by a list of operators and values.

action_json str

A list of one or more actions for each rule. Each action within the list is itself a list.

advanced_condition_json str

Contains a list of specific conditions including active-between,scheduled-weekly, and frequency-over. The first element in the list is the label for the condition, followed by a list of values for the specific condition. For more details on these conditions see Advanced Condition in the PagerDuty API documentation.

catch_all bool

A boolean that indicates whether the rule is a catch-all for the account. This field is read-only through the PagerDuty API.

condition_json str

Contains a list of conditions. The first field in the list is and or or, followed by a list of operators and values.

actionJson String

A list of one or more actions for each rule. Each action within the list is itself a list.

advancedConditionJson String

Contains a list of specific conditions including active-between,scheduled-weekly, and frequency-over. The first element in the list is the label for the condition, followed by a list of values for the specific condition. For more details on these conditions see Advanced Condition in the PagerDuty API documentation.

catchAll Boolean

A boolean that indicates whether the rule is a catch-all for the account. This field is read-only through the PagerDuty API.

conditionJson String

Contains a list of conditions. The first field in the list is and or or, followed by a list of operators and values.

Import

Event rules can be imported using the id, e.g.

 $ pulumi import pagerduty:index/eventRule:EventRule main 19acac92-027a-4ea0-b06c-bbf516519601

Package Details

Repository
PagerDuty pulumi/pulumi-pagerduty
License
Apache-2.0
Notes

This Pulumi package is based on the pagerduty Terraform Provider.